#include <bits/stdc++.h>
using namespace std;
int n, a[222000], ans;
map<int, int> was;
vector<int> v;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    was[a[i]]++;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) v.push_back(was[a[i]]);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = v[0]; i >= 1; i--) {
    int k = i, cnt = 0;
    for (int j = 0; j < v.size(); j++) {
      if (v[j] < k) break;
      cnt += k;
      if (k % 2) break;
      k /= 2;
    }
    ans = max(ans, cnt);
  }
  cout << ans;
}
