#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const long long MOD = 1e9 + 7;
const double eps = 1e-9;
struct star {
  int i, j;
  long long v;
  star(int i, int j, long long v) {
    this->i = i;
    this->j = j;
    this->v = v;
  }
  bool operator<(const star &o) const {
    if (i != o.i) return i < o.i;
    return v < o.v;
  }
};
vector<int> p, q;
int xgcd(int a, int b, int &x, int &y, int step, int &m) {
  if (step == 0)
    p.push_back(0);
  else if (step == 1)
    p.push_back(1);
  else
    p.push_back((p[step - 2] - (1ll * p[step - 1] * q[step - 2]) % m + m) % m);
  if (b == 0) {
    x = 0, y = 0;
    return a;
  }
  int x2 = 0, y2 = 0;
  q.push_back(a / b);
  int g = xgcd(b, a % b, x2, y2, step + 1, m);
  x = x2;
  y = x2 - (a / b) * y2;
  return g;
}
int mod_inverse(int a, int m) {
  int x = 0, y = 0;
  int g = xgcd(m, a, x, y, 0, m);
  if (g != 1) return -1;
  return p.back();
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int T, n, a[N], siv, g, len, ans[N];
long long s, b[N];
map<int, vector<star> > v;
int main() {
  scanf("%d%d", &T, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    if (i) b[i] = b[i - 1] + a[i];
    s += a[i];
  }
  g = gcd(s, T);
  len = T / g;
  T /= g;
  s /= g;
  s %= len;
  siv = mod_inverse(s, T);
  for (int i = 0; i < n; i++) {
    int cyc = b[i] % g, idx = (1ll * (b[i] / g) % len * siv) % len;
    v[cyc].push_back(star(idx, i, b[i] / g));
  }
  for (auto it = v.begin(); it != v.end(); it++) {
    sort(it->second.begin(), it->second.end());
    if (!it->second.size()) continue;
    vector<star> cur;
    cur.push_back(it->second[0]);
    for (int i = 1; i < it->second.size(); i++)
      if (it->second[i].i != cur.back().i) cur.push_back(it->second[i]);
    for (int i = 0; i < (int)cur.size() - 1; i++)
      ans[cur[i].j] += cur[i + 1].i - cur[i].i;
    ans[cur.back().j] += len - cur.back().i + cur[0].i;
  }
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
