#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, x;
  cin >> n;
  map<long long, long long> m;
  for (i = 0; i < n; i++) {
    cin >> x;
    m[x]++;
  }
  map<long long, long long>::iterator it;
  vector<long long> v;
  for (it = m.begin(); it != m.end(); it++) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end());
  long long len = v.size(), last = v[len - 1], cur, cur_sum, ans = 0, pos;
  for (i = 1; i <= last; i++) {
    cur = i;
    pos = len - 1;
    cur_sum = i;
    pos--;
    while (cur % 2 == 0 && pos >= 0) {
      cur = cur / 2;
      if (v[pos] < cur) break;
      cur_sum += cur;
      pos--;
    }
    ans = max(ans, cur_sum);
  }
  cout << ans << endl;
}
