#include <bits/stdc++.h>
using namespace std;
const int N = 1005505;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
int n, a[N];
map<int, int> cnt;
vector<pair<int, int> > v;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], cnt[a[i]]++;
  for (auto &x : cnt) v.push_back({x.second, x.first});
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int len = 31; len >= 0; --len) {
    long long l = 0, r = 1e9 + 3;
    while (l + 1 < r) {
      long long m = (l + r) >> 1;
      long long k = m, lc = 0;
      for (auto &x : v)
        if (x.first >= k) k <<= 1, lc++;
      if (lc >= len)
        l = m;
      else
        r = m;
    }
    long long k = l, res = 0;
    for (auto &x : v)
      if (x.first >= k) res += k, k <<= 1;
    ans = max(ans, res);
  }
  cout << ans;
  return 0;
}
