#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int MOD = 1e9 + 7;
map<int, int> Mp;
int N;
int a[maxn];
int main() {
  while (cin >> N) {
    Mp.clear();
    int t;
    for (int i = 1; i <= N; i++) {
      scanf("%d", &t);
      Mp[t]++;
    }
    t = 0;
    int Max = 0;
    for (auto i : Mp) {
      a[++t] = i.second;
      Max = max(Max, a[t]);
    }
    sort(a + 1, a + 1 + t);
    for (int i = 1; i <= a[t]; i++) {
      int res = i;
      int tp = i;
      int pos1 = lower_bound(a + 1, a + 1 + t, tp) - a;
      while (1) {
        int pos2 = lower_bound(a + pos1 + 1, a + 1 + t, tp << 1) - a;
        if (pos2 > t) break;
        pos1 = pos2;
        tp <<= 1;
        res += tp;
      }
      Max = max(Max, res);
    }
    cout << Max << endl;
  }
}
