#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
long long a[maxn];
vector<long long> v;
int32_t main() {
  long long n;
  scanf("%lld", &n);
  for (__typeof(n) i = 1; i <= (n); i++) scanf("%lld", a + i);
  sort(a + 1, a + n + 1);
  long long cnt = 1;
  for (__typeof(n) i = 1; i <= (n); i++) {
    if (a[i] == a[i + 1]) {
      cnt++;
    } else {
      v.push_back(cnt);
      cnt = 1;
    }
  }
  sort(v.begin(), v.end());
  long long len = v.size();
  long long ans = 0;
  for (__typeof(200000) i = 1; i <= (200000); i++) {
    long long t = i, now = 0;
    long long pos = -1;
    while (1) {
      long long id = lower_bound(v.begin(), v.end(), t) - v.begin();
      id = max(id, pos + 1);
      if (id == len) break;
      now += t;
      t *= 2ll;
      pos = id;
    }
    ans = max(ans, now);
  }
  printf("%lld\n", ans);
  return 0;
}
