#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, r, id;
  bool bo;
} A[210000], B[210000];
int n, s, t, a[210000], ans[210000];
map<int, bool> ma;
bool cmp(node x, node y) {
  if (x.r < y.r) return 1;
  return 0;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void exgcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return;
  }
  int t = a / b, xx, yy;
  exgcd(b, a % b, xx, yy);
  x = yy;
  y = xx - t * yy;
}
bool cmp1(node x, node y) {
  if (x.x < y.x) return 1;
  return 0;
}
void solve(int l, int r, int x) {
  int num = 0;
  for (int i = l; i <= r; i++)
    if (A[i].bo) B[++num].id = A[i].id, B[num].x = 1ll * A[i].x * x % t;
  sort(B + 1, B + num + 1, cmp1);
  for (int i = 1; i < num; i++) ans[B[i].id] = B[i + 1].x - B[i].x;
  ans[B[num].id] = t - B[num].x + B[1].x;
}
int main() {
  scanf("%d%d", &t, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s = (s + a[i]) % t;
    if (i == 1)
      a[i] = 0;
    else
      a[i] = (a[i] + a[i - 1]) % t;
    if (ma.count(a[i]) == 0) ma[a[i]] = 1, A[i].bo = 1;
  }
  int g = gcd(s, t), x, y;
  s /= g;
  t /= g;
  for (int i = 1; i <= n; i++)
    A[i].id = i, A[i].r = a[i] % g, A[i].x = a[i] / g;
  exgcd(s, t, x, y);
  x = (x % t + t) % t;
  sort(A + 1, A + n + 1, cmp);
  int i = 1;
  while (i <= n) {
    int j = i;
    while (A[j].r == A[i].r && j <= n) j++;
    solve(i, j - 1, x);
    i = j;
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
