#include <bits/stdc++.h>
using namespace std;
struct bien {
  int gt, sl;
};
bien a[200010];
map<int, int> mmap;
map<int, int>::iterator it;
int n;
int x, maxx;
int kq;
bool cmp(bien t1, bien t2) { return t1.sl < t2.sl; }
void xet(int temp) {
  int i;
  int tong = 0;
  int dau = 0;
  int gt = temp;
  while (gt <= maxx) {
    int cuoi = n - 1;
    int vt = -1;
    while (dau <= cuoi) {
      int giua = (dau + cuoi) / 2;
      if (a[giua].sl >= gt) {
        vt = giua;
        cuoi = giua - 1;
      } else
        dau = giua + 1;
    }
    if (vt == -1) break;
    dau = vt + 1;
    tong += gt;
    gt = gt * 2;
  }
  if (tong > kq) kq = tong;
}
void solve() {
  maxx = 0;
  n = 0;
  for (it = mmap.begin(); it != mmap.end(); it++) {
    a[n].gt = it->first;
    a[n].sl = it->second;
    if (a[n].sl > maxx) maxx = a[n].sl;
    n++;
  }
  sort(a, a + n, cmp);
  kq = 0;
  for (int bd = 1; bd <= maxx; bd++) {
    xet(bd);
  }
}
void output() { printf("%d\n", kq); }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    mmap[x]++;
  }
  solve();
  output();
  return 0;
}
