#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int n, T, a[N], sum, phi, ans[N], g, invsum;
map<int, int> mp;
map<int, vector<int>> cycles;
void add(int &a, int b) {
  a += b;
  if (a >= T) a -= T;
}
int power(int base, int to) {
  int ret = 1;
  while (to) {
    if (to & 1) ret = ret * 1LL * base % T;
    to >>= 1;
    base = base * 1LL * base % T;
  }
  return ret;
}
int inv(int a) { return power(a, phi - 1); }
int find(int a) {
  a -= a % g;
  a = a / g % T;
  a = a * 1LL * invsum % T;
  return a;
}
int main() {
  scanf("%d%d", &T, &n);
  int temp;
  scanf("%d", &temp);
  mp[0] = 0;
  for (int i = 1, a; i < n; i++) {
    scanf("%d", &a);
    a %= T;
    add(sum, a);
    ::a[i] = sum;
    if (mp.find(sum) == mp.end()) mp[sum] = i;
  }
  add(sum, temp % T);
  g = gcd(sum, T);
  T /= g;
  sum /= g;
  temp = phi = T;
  for (long long i = 2; i * i <= temp; i++)
    if (temp % i == 0) {
      phi /= i;
      phi *= i - 1;
      while (temp % i == 0) temp /= i;
    }
  if (temp != 1) {
    phi /= temp;
    phi *= temp - 1;
  }
  invsum = inv(sum);
  for (int i = 0; i < n; i++) cycles[a[i] % g].push_back(a[i]);
  for (auto cycle : cycles) {
    vector<pair<int, int>> v;
    sort(cycle.second.begin(), cycle.second.end());
    cycle.second.resize(unique(cycle.second.begin(), cycle.second.end()) -
                        cycle.second.begin());
    for (auto i : cycle.second) v.push_back({find(i), i});
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      int x = v[i].first;
      int y = v[(i + 1) % v.size()].first;
      if (x < y)
        ans[mp[v[i].second]] = y - x;
      else
        ans[mp[v[i].second]] = T - x + y;
    }
  }
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
}
