Problem:
Score : 1400 points

Problem Statement

Snuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i.
Snuke performs the following Q operations on this sequence. The i-th operation, described by a parameter q_i, is as follows:

Take the first q_i elements from the sequence obtained by concatenating infinitely many copy of the current sequence, then replace the current sequence with those q_i elements.

After these Q operations, find how many times each of the integers 1 through N appears in the final sequence.

Constraints

1 ≦ N ≦ 10^5

0 ≦ Q ≦ 10^5

1 ≦ q_i ≦ 10^{18}

All input values are integers.

Input

The input is given from Standard Input in the following format:

N Q
q_1
:
q_Q

Output

Print N lines. The i-th line (1 ≦ i ≦ N) should contain the number of times integer i appears in the final sequence after the Q operations.

Sample Input 1

5 3
6
4
11

Sample Output 1

3
3
3
2
0

After the first operation, the sequence becomes: 1,2,3,4,5,1.

After the second operation, the sequence becomes: 1,2,3,4.

After the third operation, the sequence becomes: 1,2,3,4,1,2,3,4,1,2,3.

In this sequence, integers 1,2,3,4,5 appear 3,3,3,2,0 times, respectively.

Sample Input 2

10 10
9
13
18
8
10
10
9
19
22
27

Sample Output 2

7
4
4
3
3
2
2
2
0
0

Solution in C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 1e9+7 ;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

const int maxn = 1e6+5;


signed main(){
    IOS();
    int n,q; cin>>n>>q;
    vector<ll> lens = {n};
    for (ll i = 0; i<q; ++i) {
        ll x; cin>>x;
        while (SZ(lens) && lens.back() >= x) lens.pop_back();
        lens.pb(x);
    }
    for (ll x : lens) bug(x);

    map<ll, ll> mp;
    mp[lens.back()] = 1;
    for (int i = SZ(lens)-2; i>=0; --i) {
        ll x = lens[i];
        for (auto & xx : mp) bug(xx.f, xx.s);
        bug("...");
        while (!mp.empty() && mp.rbegin()->f > x) {
            assert(mp.rbegin()->s > 0);
            ll y = mp.rbegin()->f % x;
            ll cop = mp.rbegin()->f / x;
            mp[y] += mp.rbegin()->s;
            if (cop) mp[x] += cop * mp.rbegin()->s;
            mp.erase(mp.rbegin()->f);
        }
    }
    vector<ll> ret(n+1);
    for (auto & xx : mp) {
        if (xx.f) ret[xx.f-1] += xx.s;
    }
    for (int i = n; i>=0; --i) {
        if (i!=n) ret[i] += ret[i+1];
    }
    for (int i = 0; i<n; ++i) {
        cout<<ret[i]<<endl;
    }
}