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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int maxn = 5e5 + 3;

map<int, int> cnt;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int max_cnt = 0;
    int a, prev;
    if (n == 1) {
        cout << 1;
        exit(0);
    }
    bool test = true;
    for (int i =  0; i < n; i++) {
        cin >> a;
        if (a != prev && i != 0) {
            test = false;
        }
        cnt[a]++;
        max_cnt = max(max_cnt, cnt[a]);
        prev = a;
    }
    if (test) {
        cout << 1;
        exit(0);
    }
    int wyn = 0;
    for (auto& u : cnt) {
        if (u.second == max_cnt) wyn++;
    }
    cout << wyn;
}