#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n, s = 0;
cout<<„Unesi broj razina, n= „;
cin >> n;
int a[n];
for(int i=0; i<n; i++)
cin >> a[i];
for(int i=n-2; i>=0; i–)
if( a[i] >= a[i+1] )
{
s =s+ (a[i] – a[i+1]) + 1;
a[i] = a[i+1] – 1;
}
cout << s << endl;
system(„PAUSE“);
return EXIT_SUCCESS;
}