#include <bits/stdc++.h>
using namespace std;
long long a[100000];
int main() {
  ios_base::sync_with_stdio(0);
  long long n, d;
  cin >> d >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long s = 0, op = 0;
  for (int i = 0; i < n; ++i) {
    if (s != 0) op += d - s;
    s = a[i] % d;
  }
  cout << op << endl;
  cin >> n;
  return 0;
}
