#include <bits/stdc++.h>
int dr[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dc[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dr_y[] = {-1, 0, 1, 0};
int dc_x[] = {0, 1, 0, -1};
using namespace std;
int a[5000];
int n;
int d;
void construct() {
  int now = (a[0] + 1);
  if (now > d) now %= d;
  int edit = 0;
  for (int i = 1; i <= n - 1; i++) {
    if (now > 1) {
      edit += d - now + 1;
      now = 1;
    }
    now += a[i];
    if (now > d) now %= d;
  }
  printf("%d", edit);
}
int main() {
  while (scanf("%d%d", &d, &n) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    construct();
  }
  return 0;
}
