#include <bits/stdc++.h>
using namespace std;
int N, K;
int A[200000];
int lw, cnt;
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  lw = A[0];
  cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (lw < A[i]) {
      lw = A[i];
    }
    cnt = cnt + lw - A[i];
  }
  cout << cnt;
}
