#include <bits/stdc++.h>
using namespace std;
long long T, n, i, j, aux, rez_d, rez_x, rez_y, limit;
long long a[200011], jump, ans[200011];
vector<pair<long long, long long> > ord, pos;
map<long long, bool> M;
long long gcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long xx, yy;
  long long d = gcd(b, a % b, xx, yy);
  x = yy;
  y = xx - yy * (a / b);
  return d;
}
void solve(long long l, long long r) {
  long long i, j;
  long long bonus = ord[l].first % rez_d;
  long long d, x, y;
  pos.clear();
  for (i = l; i <= r; i++) {
    ord[i].first -= bonus;
    d = rez_d;
    x = rez_x;
    x *= ord[i].first / d;
    y = rez_y;
    y *= ord[i].first / d;
    x = ((x % limit) + limit) % limit;
    pos.push_back(make_pair(x, ord[i].second));
  }
  sort(pos.begin(), pos.end());
  if (pos.size() == 1) {
    ans[pos[0].second] += limit;
    return;
  }
  pos.push_back(pos[0]);
  for (i = 1; i < pos.size(); i++) {
    auto p1 = pos[i - 1];
    auto p2 = pos[i];
    long long cnt = (p2.first - p1.first + limit) % limit;
    ans[p1.second] += cnt;
  }
}
int main() {
  scanf("%lld%lld", &T, &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]), jump += a[i];
  jump %= T;
  aux = -a[1];
  for (i = 1; i <= n; i++) {
    aux += a[i];
    aux %= T;
    if (M[aux]) continue;
    M[aux] = true;
    ord.push_back(make_pair(aux, i));
  }
  rez_d = gcd(jump, T, rez_x, rez_y);
  limit = T / rez_d;
  sort(ord.begin(), ord.end(),
       [](const pair<long long, long long>& a,
          const pair<long long, long long>& b) -> bool const {
         return a.first % rez_d < b.first % rez_d;
       });
  for (i = 0; i < ord.size(); i = j) {
    for (j = i; j < ord.size(); j++)
      if (ord[i].first % rez_d != ord[j].first % rez_d) break;
    solve(i, j - 1);
  }
  for (i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return 0;
}
