#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int d, n;
  cin >> d >> n;
  int x;
  int curr = 0;
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (curr == 0) {
      curr = curr + x;
      continue;
    } else {
      count += (d - curr);
      curr = 0;
      curr += x;
    }
  }
  cout << count;
  return 0;
}
