#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int n;
  cin >> n;
  long long int a[n + 1];
  map<long long, long long> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  long long ans = 0;
  multiset<long long> s;
  for (auto it = m.begin(); it != m.end(); it++) {
    s.insert(it->second);
    ans = max(ans, it->second);
  }
  vector<long long int> v1;
  long long ans2 = 0, ans1 = 0;
  for (i = 1; i <= ans; i++) {
    v1.clear();
    long long p = i;
    ans1 = 0;
    while (1) {
      auto it = s.lower_bound(p);
      if (it == s.end()) break;
      v1.push_back(*it);
      s.erase(s.find(*it));
      ans1 += p;
      p = p * 2;
    }
    ans2 = max(ans2, ans1);
    for (j = v1.size() - 1; j >= 0; j--) {
      s.insert(v1[j]);
    }
  }
  cout << ans2 << endl;
}
