#include <bits/stdc++.h>
using namespace std;
int f(int a, int n) { return a * ((1 << n) - 1); }
int n, x;
map<int, int> koyta;
vector<int> ashol;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    koyta[x]++;
  }
  for (auto it : koyta) ashol.push_back(it.second);
  sort(ashol.begin(), ashol.end());
  int ans = 0;
  for (int st = 1; st <= 200000; st++) {
    int cur = st;
    int in = 0;
    int curans = 0;
    while (true) {
      int x = lower_bound(ashol.begin() + in, ashol.end(), cur) - ashol.begin();
      if (x < ashol.size()) {
        curans += cur;
        ans = max(ans, curans);
        cur *= 2;
        in = x + 1;
      } else
        break;
    }
  }
  cout << ans << endl;
  return 0;
}
