#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]);
}

### Prompt

Please provide a CPP coded solution to the problem described below:

After studying the beacons Mister B decided to visit alien's planet, because he learned that they live in a system of flickering star Moon. Moreover, Mister B learned that the star shines once in exactly T seconds. The problem is that the star is yet to be discovered by scientists.

There are n astronomers numerated from 1 to n trying to detect the star. They try to detect the star by sending requests to record the sky for 1 second. 

The astronomers send requests in cycle: the i-th astronomer sends a request exactly ai second after the (i - 1)-th (i.e. if the previous request was sent at moment t, then the next request is sent at moment t + ai); the 1-st astronomer sends requests a1 seconds later than the n-th. The first astronomer sends his first request at moment 0.

Mister B doesn't know the first moment the star is going to shine, but it's obvious that all moments at which the star will shine are determined by the time of its shine moment in the interval [0, T). Moreover, this interval can be split into T parts of 1 second length each of form [t, t + 1), where t = 0, 1, 2, ..., (T - 1).

Mister B wants to know how lucky each astronomer can be in discovering the star first.

For each astronomer compute how many segments of form [t, t + 1) (t = 0, 1, 2, ..., (T - 1)) there are in the interval [0, T) so that this astronomer is the first to discover the star if the first shine of the star happens in this time interval.

Input

The first line contains two integers T and n (1 ≤ T ≤ 109, 2 ≤ n ≤ 2·105).

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print n integers: for each astronomer print the number of time segments describer earlier.

Examples

Input

4 2
2 3


Output

3 1 


Input

5 4
1 1 1 1


Output

2 1 1 1 

Note

In the first sample test the first astronomer will send requests at moments t1 = 0, 5, 10, ..., the second — at moments t2 = 3, 8, 13, .... That's why interval [0, 1) the first astronomer will discover first at moment t1 = 0, [1, 2) — the first astronomer at moment t1 = 5, [2, 3) — the first astronomer at moment t1 = 10, and [3, 4) — the second astronomer at moment t2 = 3.

In the second sample test interval [0, 1) — the first astronomer will discover first, [1, 2) — the second astronomer, [2, 3) — the third astronomer, [3, 4) — the fourth astronomer, [4, 5) — the first astronomer.

### Response

```cpp
#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]);
}

```