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
#ifdef _MSC_VER
#ifndef __GNUC__
#pragma warning(disable: 4996)
#endif
#define main main1
#endif
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long           ll;
typedef unsigned long long ull;
typedef unsigned int      uint;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int n, wynik = 0;
  vector<int> elementy;

  cin >> n;
  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }
  elementy.resize(n+1);
  for(int i = 0, j; i < n; ++i) {
    cin >> j;
    ++elementy[j];
  }
  sort(elementy.begin(), elementy.end(), greater<int>());
  for(vector<int>::iterator it = elementy.begin(); n > 0; ++it) {
    n -= *it * 2 - 1;
    ++wynik;
  }
  cout << wynik << endl;

  return 0;
}