#include <bits/stdc++.h>
using namespace std;
char getc() {
  char c = getchar();
  while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9'))
    c = getchar();
  return c;
}
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
int n, a[200010], b[200010], cnt[200010], tot;
bool check(int k, int s) {
  int t = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] >= k) t++, k <<= 1;
    if (t == s) return 1;
  }
  return 0;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) b[i] = a[i] = read();
  sort(b + 1, b + n + 1);
  int t = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(b + 1, b + t + 1, a[i]) - b;
  for (int i = 1; i <= n; i++) cnt[a[i]]++;
  sort(cnt + 1, cnt + t + 1);
  for (int i = 1; i <= t; i++) a[i] = cnt[i];
  int tmp = n;
  n = t;
  for (int i = 1; i <= 18; i++) {
    int l = 1, r = tmp, ans = 0;
    while (l <= r) {
      int mid = l + r >> 1;
      if (check(mid, i))
        ans = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    tot = max(tot, ans * ((1 << i) - 1));
  }
  cout << tot;
  return 0;
}
