#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int n, a[maxn];
int main() {
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  cout << a[n - 1] * n - sum << endl;
  return 0;
}
