#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(const ll a, const ll b) { return b == 0 ? a : gcd(b, a % b); }
pair<ll, ll> bezout(const ll m1, const ll m2) {
  if (m2 == 0)
    return {1, 0};
  else {
    ll a1, a2;
    tie(a1, a2) = bezout(m2, m1 % m2);
    return {a2, a1 - a2 * (m1 / m2)};
  }
}
ll mod(const ll x, const ll m) { return x % m >= 0 ? x % m : x % m + m; }
int main() {
  ios::sync_with_stdio(false);
  int T, n;
  cin >> T >> n;
  int a0;
  cin >> a0;
  vector<ll> xs(n);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    xs[i] = xs[i - 1] + a;
  }
  const ll M = xs[n - 1] + a0;
  const ll g = gcd(M, T);
  map<ll, vector<int>> by_residue;
  for (int i = 0; i < n; i++) by_residue[xs[i] % g].push_back(i);
  vector<ll> answers(n);
  const ll M_inverse = bezout(M / g, T / g).first;
  for (auto& kv : by_residue) {
    set<ll> seen;
    vector<pair<ll, ll>> points;
    for (const int i : kv.second) {
      const ll y = mod(M_inverse * mod(-xs[i] / g, T / g), T / g);
      if (seen.count(y))
        continue;
      else
        seen.insert(y);
      points.push_back({y, i});
    }
    sort(begin(points), end(points));
    points.push_back({begin(points)->first + T / g, begin(points)->second});
    for (auto i = begin(points); next(i) != end(points); i++)
      answers[next(i)->second] = next(i)->first - i->first;
  }
  for (const ll x : answers) cout << x << " ";
  cout << endl;
}
