#include <bits/stdc++.h>
using namespace std;
int ans;
int main() {
  int d, n, u, i, prev;
  cin >> d >> n;
  for (i = 0; i < n; i++) {
    cin >> u;
    if (i and prev != 1) ans += d - prev + 1;
    prev = u + 1;
    if (prev > d) prev -= d;
  }
  cout << ans;
  return 0;
}
