#include <bits/stdc++.h>

using namespace std;

long long N, ans, mx;

int main()
{
    cin >> N;
    long long arr[N];
    for (long long i = 0 ; i < N ; i ++) {
        cin >> arr[i];
    }
    for (long long i = 0 ; i < N ; i ++) {
        mx = max(mx, arr[i]);
        ans += hell - arr[i];
    }
    cout << ans;
    return 0;
}