#include <bits/stdc++.h>
using namespace std;
const int maxn = 2E5 + 77;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void ex_gcd(int a, int b, int &d, long long &x, long long &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
    return;
  }
  ex_gcd(b, a % b, d, y, x);
  y -= (a / b) * x;
}
int T, N, A[maxn], D, S = 0;
int div(long long a, long long b, int mod) {
  if (mod == 1) return 0;
  int d;
  long long x, y;
  ex_gcd(b, mod, d, x, y);
  x *= (a / d);
  x %= (mod / d);
  return x;
}
int calc(int st) { return div(st / D, S / D, T / D); }
struct NODE {
  int v, id;
  bool operator<(const NODE &o) const { return v < o.v; }
};
map<int, set<NODE> > M;
map<int, int> vis;
int ans[maxn];
int main() {
  scanf("%d%d", &T, &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", A + i);
    S += A[i];
    if (S > T) S %= T;
  }
  D = gcd(S, T);
  A[0] = 0;
  if (A[1] > T) A[1] %= T;
  for (int i = 2; i < N; ++i) {
    A[i] += A[i - 1];
    if (A[i] > T) A[i] %= T;
  }
  for (int i = 0; i < N; ++i) {
    if (vis[A[i]])
      continue;
    else
      vis[A[i]] = true;
    int k = calc(A[i]);
    M[A[i] % D].insert((NODE){k, i});
  }
  for (map<int, set<NODE> >::iterator it = M.begin(); it != M.end(); ++it) {
    for (set<NODE>::iterator sit = it->second.begin(), ne = sit;
         sit != it->second.end();) {
      ++ne;
      if (ne == it->second.end()) {
        ans[sit->id] = it->second.begin()->v - sit->v + (T / D);
      } else {
        ans[sit->id] = ne->v - sit->v;
      }
      sit = ne;
    }
  }
  printf("%d", ans[0]);
  for (int i = 1; i < N; ++i) {
    printf(" %d", ans[i]);
  }
  printf("\n");
}
