#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dprint(T begin, T end) {
  for (auto i = begin; i != end; i++) {
    cerr << (*i) << " ";
  }
  cerr << "\n";
}
long long T;
long long now;
long long gcd(long long a, long long b) {
  while (b) {
    long long q = a % b;
    a = b;
    b = q;
  }
  return a;
}
long long gcdex(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = gcdex(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long bck(long long a, long long MOD) {
  long long x, y;
  long long g = gcdex(a, MOD, x, y);
  assert(g == 1);
  x = (x % MOD + MOD) % MOD;
  assert((x * a) % MOD == 1);
  return x;
}
map<long long, int> mm;
map<long long, vector<pair<long long, int>>> go;
long long bc;
long long ans[220000];
void solve(vector<pair<long long, int>> vv) {
  for (int i = 0; i < vv.size(); ++i) vv[i].first = (vv[i].first * bc) % T;
  sort(vv.begin(), vv.end());
  if (vv.size() == 1) {
    ans[vv[0].second] = T;
    return;
  }
  for (int i = 0; i < vv.size(); ++i) {
    long long nx = 0;
    if (i == vv.size() - 1)
      nx = vv[0].first;
    else
      nx = vv[i + 1].first;
    ans[vv[i].second] = (nx + T - vv[i].first) % T;
  }
}
int n;
int main() {
  scanf("%lld%d", &T, &n);
  for (int i = 0; i < n; ++i) {
    long long x;
    scanf("%lld", &x);
    now += x;
    now %= T;
    if (mm.count(now) == 0) {
      mm[now] = i;
    }
  }
  if (now == 0) {
    for (auto it : mm) ans[it.second] = 1;
    for (int i = 0; i < n; ++i) printf("%lld ", ans[i]);
    printf("\n");
    return 0;
  }
  long long g = gcd(now, T);
  now /= g;
  T /= g;
  bc = bck(now, T);
  for (auto i : mm) {
    go[i.first % g].push_back(make_pair(i.first / g, i.second));
  }
  for (auto it : go) {
    solve(it.second);
  }
  for (int i = 0; i < n; ++i) {
    printf("%lld ", ans[i]);
  }
  printf("\n");
  return 0;
}
