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
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<long long,long long>
using namespace std;
using ll = long long;
using ld = long double;

constexpr int SIZE = 1e7+7;

set<int> ST;
vector<int> Q;
int kub[SIZE];

int SOLVE(int n){
    int d = ST.size();
    if (d<3) return d;

    int mk = 2*n/d;

    int best = 0;
    
    for (int k=2; k<=mk; k++){
        auto it = ST.begin();
        auto stp = ST.end();

        while (it != stp){
            Q.push_back((*it)%k);
            kub[(*it)%k] ++;
            it = next(it);
        }

        for (int i=0; i<d; i++){
            best = max(best, kub[Q[i]]);
            kub[Q[i]] = 0;
        }
        Q.clear();

    }

    return best;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, q;
    cin >> n >> q;
    
    int a;

    for (int i=0; i<q; i++){
        cin >> a;

        auto it = ST.find(a);
        if (it == ST.end()) ST.insert(a);
        else ST.erase(it);

        cout << SOLVE(n) << '\n';
    }

return 0;}