#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, mi, mav, va;
  scanf("%lld", &n);
  vector<long long> v;
  long long i, sum = 0;
  for (i = 0; i < n; i++) {
    scanf("%lld", &va);
    v.push_back(va);
    sum = sum + v[i];
  }
  mav = *max_element(v.begin(), v.end());
  mi = ((n * mav) - (sum));
  cout << mi << "\n";
  return 0;
}
