#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 1;
int n, ans, now, maxv;
int A[M], tot, sum[M];
struct node {
  int v, sze;
  node() {}
  node(int a, int b) : v(a), sze(b) {}
  bool operator<(const node &a) const {
    return sze < a.sze || (sze == a.sze && v < a.v);
  }
} ls[M];
int find(int l, int val) {
  int r = tot, mid, ans = n + 1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (ls[mid].sze >= val)
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  sort(A + 1, A + n + 1);
  for (int i = 1; i <= n; i++) {
    if (A[i] != A[i - 1])
      ls[++tot] = node(A[i], 1);
    else
      ++ls[tot].sze;
    if (ls[tot].sze > maxv) maxv = ls[tot].sze;
  }
  sort(ls + 1, ls + tot + 1);
  for (int i = 1; i <= tot; i++) sum[i] = sum[i - 1] + ls[i].sze;
  for (int b = maxv, v; b >= 1; b--) {
    v = 0;
    now = b;
    int all = n, lastp = 1;
    while (now <= maxv) {
      int p = find(lastp, now);
      if (p > n) break;
      v += now;
      now <<= 1;
      all -= sum[p] - sum[lastp - 1];
      lastp = p + 1;
      if (v + all < ans) break;
    }
    if (v > ans) ans = v;
  }
  printf("%d\n", ans);
  return 0;
}
