#include <bits/stdc++.h>
using namespace std;
map<int, int> op;
int main() {
  int n;
  cin >> n;
  int a[n];
  int i;
  vector<pair<int, int> > opp;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    op[a[i]]++;
  }
  map<int, int>::iterator it = op.begin();
  for (it; it != op.end(); it++) {
    opp.push_back(make_pair(it->second, it->first));
  }
  sort(opp.begin(), opp.end());
  long long maxx = 0;
  for (i = 1; i <= n; i++) {
    int must = i;
    int id = 0;
    long long res = 0;
    while (1) {
      int o = lower_bound(opp.begin() + id, opp.end(), make_pair(must, -1)) -
              opp.begin();
      if (o < opp.size()) {
        res += must;
        must *= 2;
        id = o + 1;
      } else {
        maxx = max(maxx, res);
        break;
      }
    }
  }
  cout << maxx;
  return 0;
}
