#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
map<int, int> ma;
int n, x, num;
int getId(int x) {
  if (ma.count(x) == 0) {
    ma[x] = num++;
  }
  return ma[x];
}
int cnt[maxn];
vector<int> v;
int main() {
  while (~scanf("%d", &n)) {
    memset(cnt, 0, sizeof(cnt));
    num = 1;
    ma.clear();
    v.clear();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      cnt[getId(x)]++;
      x = getId(x);
    }
    for (int i = 0; i <= n + 1; i++) {
      if (cnt[i] != 0) v.push_back(cnt[i]);
    }
    sort(v.begin(), v.end());
    int now = 0, ans = 0;
    int len = v.size();
    for (int i = 1; i <= v[len - 1]; i++) {
      int sum = 0;
      now = 0;
      for (int j = i;;) {
        int pos = lower_bound(v.begin() + now, v.end(), j) - v.begin();
        if (pos == len) break;
        now = pos + 1;
        sum += j;
        j = j * 2;
      }
      ans = max(ans, sum);
    }
    printf("%d\n", ans);
  }
  return 0;
}
