#include <bits/stdc++.h>
using namespace std;
int get() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-') {
    int s = 0;
    while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
    return -s;
  }
  int s = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
  return s;
}
const int N = 2e5 + 5;
int n;
long long T, S;
int a[N];
set<int> s;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
bool ext[N];
int key[N];
int k;
map<int, int> id;
int ans[N];
set<long long> val[N];
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  long long tx, ty;
  exgcd(b, a % b, tx, ty);
  x = ty;
  y = tx - (a / b) * ty;
}
int main() {
  T = get();
  n = get();
  for (int i = 1; i <= n; i++) {
    a[i] = get();
    S = S + a[i];
  }
  int w = -a[1];
  for (int i = 1; i <= n; i++) {
    w = (w + a[i]) % T;
    key[i] = w;
    if (s.find(w) == s.end()) {
      s.insert(w);
      ext[i] = 1;
    }
  }
  if (S % T == 0) {
    for (int i = 1; i <= n; i++) {
      if (ext[i])
        putchar('1');
      else
        putchar('0');
      putchar(' ');
    }
    putchar('\n');
    return 0;
  }
  long long g = gcd(S, T);
  long long d = S % T;
  d /= g, T /= g;
  long long inv, tmp;
  exgcd(d, T, inv, tmp);
  inv = (inv % T + T) % T;
  for (int i = 1; i <= n; i++)
    if (ext[i]) {
      long long x = key[i];
      long long res = x % g;
      if (!id[res]) id[res] = ++k;
      val[id[res]].insert(((x - res) / g + T) % T * inv % T);
    }
  for (int i = 1; i <= n; i++)
    if (ext[i]) {
      long long x = key[i];
      long long res = x % g;
      int Id = id[res];
      long long tmp = ((x - res) / g + T) % T * inv % T;
      if (val[Id].upper_bound(tmp) != val[Id].end()) {
        ans[i] = (*(val[Id].upper_bound(tmp))) - tmp;
      } else
        ans[i] = (*val[Id].begin()) + T - tmp;
    }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  putchar('\n');
  return 0;
}
