#include <bits/stdc++.h>
using namespace std;
int n, c[100000], m = 0, sm = 0, x = 0;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
  }
  for (int i = 0; i < n; ++i) {
    m = max(m, c[i]);
    sm += c[i];
  }
  printf("%d", m * n - sm);
  return 0;
}
