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++ (GCC 9.2.1) (judge verdict: Accepted)

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define xx first
#define yy second
#define ln 17
#define off 2002

#define IN freopen("circular_circles_input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define sq(x) ((x)*(x))

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;


#define log 20
#define mod 1000000007LL
#define INF 1000000000000000000LL
#define maxn 1000005

const long double eps = 1e-9 ;

i64 a[maxn] ;

int main()
{
    int n , q ;

    scanf("%d %d",&n,&q) ;

    vector <i64> v ;
    v.pb(n) ;

    for(int i=1 ; i<=q ; i++)
    {
        i64 x ;
        scanf("%lld",&x) ;
        while( v.size() > 0 && v.back() >= x ) v.pop_back() ;
        v.push_back(x) ;
    }

    map<i64,i64> cnt ;

    cnt[ v.back() ] = 1 ;

    reverse(v.begin(),v.end()) ;

    for(int i=0; i+1<v.size() ; i++)
    {
      //  printf("-- %lld\n",v[i]) ;
        i64 full = v[i+1] ;
        i64 fullCnt = 0 ;

        while( cnt.size() > 0 )
        {
            map<i64,i64> :: iterator it = cnt.end() ;
            it-- ;

            if( it->xx <= v[i+1] ) break ;

            pair<i64,i64> p = *it ;
            cnt.erase(it) ;

            fullCnt += ( p.xx/full )*p.yy ;
            if( p.xx%full != 0 )
            {
                i64 sz = p.xx%full ;
                if( cnt.find( sz ) == cnt.end() ) cnt[sz] = 0 ;
                cnt[ sz ] += p.yy ;
            }
        }
        if( cnt.find(full) == cnt.end() ) cnt[full] = 0 ;
        cnt[full] += fullCnt ;
    }

    for(auto p:cnt) a[ p.xx ] += p.yy ;

    for(int i=n ; i>=1 ; i--) a[i] += a[i+1] ;

    for(int i=1 ; i<=n ; i++) printf("%lld\n",a[i]) ;

    return 0 ;
}