#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool Max(T1& a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T1, typename T2>
bool Min(T1& a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
T gcd_ext(T a, T b, T& x, T& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  T g = gcd_ext(b, a % b, y, x);
  y -= (a / b) * x;
  return g;
}
const int N = 200001;
int ans[N];
void solve() {
  int T, n, a;
  cin >> T >> n;
  int per = 0;
  map<int, int> m;
  m[0] = 0;
  cin >> per;
  int loc = 0;
  for (int i = 1; i <= (n - 1); ++i) {
    cin >> a;
    per = (per + a) % T;
    loc = (loc + a) % T;
    m.emplace(loc, i);
  }
  int perinv, Tinv;
  int g = gcd_ext(per, T, perinv, Tinv);
  per /= g;
  T /= g;
  map<int, vector<pair<int, int>>> mv;
  for (auto& e : m) {
    mv[e.first % g].emplace_back((long long)perinv * (e.first / g) % T,
                                 e.second);
  }
  for (auto& e : mv) {
    auto& vec = e.second;
    sort(vec.begin(), vec.end());
    vec.emplace_back(vec[0].first + T, 0);
    for (int i = 0; i < (vec.size() - 1); ++i)
      ans[vec[i].second] = vec[i + 1].first - vec[i].first;
  }
  for (int i = 0; i < (n); ++i) cout << ans[i] << ' ';
  cout << '\n';
}
void init() {}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  init();
  int TC = 1;
  for (int TI = 1; TI <= (TC); ++TI) {
    solve();
  }
  return 0;
}
