#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
  
  
int main(){
	ll n;
  	cin >> n;
  
  	vector<ll> a(N);
    for(int i = 0;i < N;i++){
		cin >> a[i];
    }
  
    ll tmp = a[0];
    ll ans = 0;
    
    for(int i = 1;i < N ;i++){
    	ans += max((ll)0,tmp - a[i]);
        tmp = max(tmp,a[i]);
    }
}
