#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long INF = 1e15;
int n;
long long a[N], cnt[N];
int main() {
  scanf("%d\n", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d\n", &a[i]);
  sort(a + 1, a + n + 1);
  int lst = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || a[i] != a[i - 1]) lst++;
    cnt[lst]++;
  }
  sort(cnt + 1, cnt + lst + 1);
  long long ans = 0;
  int ptr = 1;
  for (long long i = 1; i <= cnt[lst]; i++) {
    long long len = 1, now = 1;
    while (i > cnt[ptr]) ptr++;
    for (long long j = i * 2; j <= cnt[lst]; j *= 2) {
      now++;
      if (now > lst - ptr + 1) break;
      long long lb = lower_bound(cnt + ptr, cnt + lst + 1, j) - cnt,
                ub = lower_bound(cnt + ptr, cnt + lst + 1, j * 2) - cnt,
                cur = ub - lb;
      if (lb > lst) break;
      len += min(now - len, ub - lb);
    }
    ans = max(ans, (((long long)1 << len) - 1) * i);
  }
  printf("%I64d", ans);
}
