#include <bits/stdc++.h>
const bool TEST = 1;
const int inf = 0x7fffffff;
using namespace std;
template <typename T>
void pA(T *begin, int n) {
  for (int i = 0; i < n; i++) {
    cout << *(begin++);
  }
  printf("\n");
}
void sol() {
  int n;
  long long int s = 0;
  int m = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    s += x;
    m = max(x, m);
  }
  cout << m * n - s << endl;
}
int main() {
  sol();
  return 0;
}
