#include <bits/stdc++.h>
using namespace std;
const double pai = acos(-1.0);
const double E = 2.718281828459;
const long long mod = 1e9 + 7;
int main() {
  int n, x, num[200005], sign = 0;
  map<int, int> q;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    q[x]++;
  }
  map<int, int>::iterator u = q.begin();
  for (; u != q.end(); u++) num[++sign] = u->second;
  sort(num + 1, num + 1 + sign);
  int up = num[sign], ans = 0;
  for (int i = 1; i <= up; i++) {
    int cnt = 0, s = 1, j = i;
    while (s <= sign &&
           (s = (lower_bound(num + s, num + 1 + sign, j) - num)) != sign + 1) {
      cnt += j;
      j = j << 1;
      s++;
    }
    ans = max(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}
