#include <bits/stdc++.h>
using namespace std;
inline int max(int a, int b) { return a > b ? a : b; }
map<int, int> mp;
int a[200005], id;
inline int read(int x) {
  if (mp.count(x) > 0) return mp[x];
  mp[x] = ++id;
  return id;
}
int main() {
  int n;
  scanf("%d", &n);
  int x;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    ++a[read(x)];
  }
  sort(a + 1, a + 1 + id);
  int ans = 0, last, now, pos;
  for (int i = 1; i <= n; ++i) {
    last = 1;
    now = 0;
    for (int k = i; k <= n; k <<= 1) {
      pos = lower_bound(a + last, a + id + 1, k) - a;
      if (pos > id) break;
      now += k;
      last = pos + 1;
    }
    ans = max(ans, now);
  }
  printf("%d\n", ans);
}
