#include <bits/stdc++.h>
using namespace std;
int main() {
  int max_d, month, i, temp, day = 0, cnt = 0;
  cin >> max_d >> month;
  int arr[month];
  for (i = 0; i < month; i++) cin >> arr[i];
  temp = max_d;
  i = 0;
  while (month != 0) {
    if (day == 0) {
      while (arr[i] != 0) {
        arr[i]--;
        day++;
      }
      day = day % max_d;
      month--;
      i++;
    } else {
      cnt += max_d - day;
      day = 0;
    }
  }
  cout << cnt;
  return 0;
}
