#include <bits/stdc++.h>
int main() {
  int d, n;
  int a;
  while (scanf("%d", &d) != EOF) {
    scanf("%d", &n);
    int i, c = 1, sum = 0;
    while (n--) {
      sum += (d - c + 1) % d;
      c = 1;
      scanf("%d", &a);
      c = (c + a) % d;
      if (c == 0) c = d;
    }
    printf("%d\n", sum);
  }
  return 0;
}
