#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long maxn = 1e5 + 1;
const long long inf = 5e18;
const long long minf = -inf;
bool solve() {
  long long n, ans = 0;
  cin >> n;
  map<long long, long long> cnt;
  for (long long i = 0, x; i < n; ++i) {
    cin >> x;
    cnt[x]++;
  }
  multiset<long long> s;
  for (auto x : cnt) s.insert(x.second);
  for (long long i = 1; i <= n; ++i) {
    long long cnt = 0;
    multiset<long long> rem;
    for (long long j = 0; j < 20; ++j) {
      long long find = i << j;
      auto it = s.lower_bound(find);
      if (it == s.end())
        break;
      else {
        cnt += i << j;
        rem.insert(*it);
        s.erase(it);
      }
    }
    ans = max(ans, cnt);
    for (auto x : rem) s.insert(x);
  }
  cout << ans << "\n";
  return true;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    if (solve()) {
    } else {
    }
  }
  return 0;
}
