#include <bits/stdc++.h>
int main() {
  int x, y = 0, i = 1, j = 1, n = 0, q, a[102];
  scanf("%d", &x);
  for (i = 1; i <= x; i++) {
    scanf("%d", &a[i]);
    if (a[i] > y) y = a[i];
  }
  for (i = 1; i <= x; i++) {
    q = y - a[i];
    n = n + q;
  }
  printf("%d\n", n);
  return 0;
}
