1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define RFOR(i, a, b) for(int i = (int)a; i >= (int)b; --i)
#define in insert
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
using namespace std;

const int MAX = 1e6 + 7;
char tab[MAX];
int md[MAX], dp[MAX];
vector<int> pos;
int n, q;

void solve() {
    int m = 0;
    pos.clear();
    FOR(i, 1, n) {
        if(tab[i] == '#') {
            pos.pb(i);
            ++m;
        }
    }
    if(m == 0) {
        cout << 0 << '\n';
        return;
    }
    int rozm = (2 * n) / m, res = 0;
    FOR(i, 2, rozm) {
        FOR(j, 0, m - 1) {
            int akt = pos[j];
            ++dp[akt % i];
            res = max(res, dp[akt % i]);
        }
        FOR(j, 0, m - 1) {
            int akt = pos[j];
            dp[akt % i] = 0;
        }
    }
    cout << res << '\n';
}

int gc() {
    char x;
    while(true) {
        x = getchar_unlocked();
        if(x >= '0' && x <= '9') break;
    }
    int num = x - '0';
    while(true) {
        x = getchar_unlocked();
        if(x >= '0' && x <= '9') {
            num *= 10;
            num += (x - '0');
        } else break;
    }
    return num;
} 

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    n = gc(), q = gc();
    FOR(i, 1, n) tab[i] = '.';
    while(q--) {
        int x = gc();
        if(tab[x] == '.') tab[x] = '#';
        else tab[x] = '.';
        solve();
    }
    return 0;
}