#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265359;
const long long MOD = (long long)998244353ll;
const long long MAXN = (long long)2e5 + 10;
const long long INF = (long long)9223372036854775;
const long double EPS = (long double)1e-8;
long long a[MAXN];
map<long long, long long> ma;
vector<long long> cnt;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long v;
  for (int i = 0; i < n; i++) {
    cin >> v;
    ma[v]++;
  }
  for (auto x : ma) cnt.push_back(x.second);
  sort(cnt.begin(), cnt.end());
  cnt.push_back(INF);
  long long m = cnt.size();
  cerr << "m"
       << " = " << m << endl;
  for (int i = 0; i < m; i++) a[i] = cnt[i];
  long long ans = 0;
  long long pr, po;
  long long f;
  long long up;
  for (int i = 1; i <= n; i++) {
    po = 0;
    pr = 0;
    f = i;
    while (true) {
      if (po >= m - 1) break;
      up = po + (upper_bound(a + po, a + m, f - 1) - (a + po));
      if (up >= m - 1) break;
      po = up + 1;
      pr += f;
      f *= 2ll;
    }
    ans = max(ans, pr);
  }
  cout << ans;
  return 0;
}
