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: Wrong Answer)

//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=2e5+7;
typedef long long LL; 
typedef double db;
using namespace std;
int n,q;
LL a[N],cnt[N],ans[N];

template<typename T> void read(T &x) {
    char ch=getchar(); x=0; T f=1;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}

LL sg[N<<2];
#define lc x<<1
#define rc ((x<<1)|1)
#define mid ((l+r)>>1)
void build(int x,int l,int r) {
	if(l==r) { sg[x]=a[l]; return ; }
	build(lc,l,mid); build(rc,mid+1,r);
	sg[x]=min(sg[lc],sg[rc]);
}

int qry(int x,int l,int r,int ql,int qr,LL v) {
	if(ql>qr) return 0;
	if(l>=ql&&r<=qr) {
		if(sg[x]>v) return 0;
		if(l==r) return l;
		if(sg[rc]<=v) return qry(rc,mid+1,r,ql,qr,v);
		if(sg[lc]<=v) return qry(lc,l,mid,ql,qr,v); 
	}
	if(qr<=mid) return qry(lc,l,mid,ql,qr,v);
	int rs=qry(rc,mid+1,r,ql,qr,v);
	if(rs) return rs; else return qry(lc,l,mid,ql,qr,v);	
}

LL cf[N];
void solve(int x,LL l,LL c) {
	if(!x||!l) {
		if(!x) cf[l]+=c;
		return ;
	}
	//cnt[x-1]+=l/a[x-1]*c;
	int y=qry(1,1,n,1,x-1,l);
	cnt[y]+=l/a[y]*c;
	solve(y,l%a[y],c);
}

//#define DEBUG
int main() {
#ifdef DEBUG
	freopen("1.in","r",stdin);
	//freopen(".out","w",stdout);
#endif
	read(n); read(q); a[0]=n;
	For(i,1,q) read(a[i]);
	build(1,1,n); cnt[q]=1;
	Rep(i,q,1) if(cnt[i]) 
		solve(i,a[i],cnt[i]);
	ans[n+1]=cnt[0];
	Rep(i,n,1) ans[i]=ans[i+1]+cf[i];
	For(i,1,n) printf("%lld\n",ans[i]);
    return 0;
}