#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
struct node {
  int val, cnt;
  friend bool operator<(const node n1, const node n2) {
    return n1.cnt > n2.cnt;
  }
} a[maxn];
int n, s[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  sort(s + 1, s + n + 1);
  int len = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] != s[i - 1]) {
      len++;
      a[len].val = s[i];
      a[len].cnt = 1;
    } else
      a[len].cnt++;
  }
  sort(a + 1, a + len + 1);
  int now = a[1].cnt;
  int day = 1;
  long long ans = a[1].cnt;
  for (int i = 2; i <= len; i++) {
    now = now / 2;
    if (now == 0) break;
    if (a[i].cnt <= now) now = a[i].cnt;
    day++;
    ans = max(((1LL << day) - 1) * now, ans);
  }
  printf("%I64d\n", ans);
  return 0;
}
