#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007, N = 200010;
long long T, n, m, q[N], a[N], C, b[N], ms;
bool v[N];
map<long long, int> mp;
set<int> s[N];
int exgcd(long long a, long long b, long long &x, long long &y) {
  int z;
  return !b ? (x = 1, y = 0, a)
            : (z = exgcd(b, a % b, y, x), y -= x * (a / b), z);
}
int main() {
  scanf("%I64d%I64d", &T, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    (a[i] += a[i - 1]) %= T;
  }
  C = a[n];
  if (!C) C += T;
  long long x, y, d, z;
  d = exgcd(C, T, x, y);
  C /= d, T /= d;
  x = x % T + T;
  for (int i = 1; i <= n; i++) {
    q[i] = a[i] % d;
    a[i] /= d;
    b[i] = x * a[i] % T;
    if (!mp[q[i]]) mp[q[i]] = ++ms;
    q[i] = mp[q[i]];
    if (s[q[i]].find(b[i]) != s[q[i]].end())
      v[i] = 1;
    else
      s[q[i]].insert(b[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (v[i]) {
      printf("0 ");
      continue;
    }
    z = q[i];
    auto it = s[z].find(b[i]);
    auto tmp = it;
    if ((++tmp) == s[z].end()) tmp = s[z].begin();
    printf("%d ", ((*tmp) - b[i] + T - 1) % T + 1);
  }
  return 0;
}
