#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<int, int> occTable;
  for (int(i) = 0; (i) < (N); (i)++) {
    int t;
    cin >> t;
    occTable[t]++;
  }
  vector<int> occ;
  for (auto const& e : occTable) occ.push_back(e.second);
  sort(occ.rbegin(), occ.rend());
  int best = occ[0];
  int cur = occ[0];
  for (int(i) = 1; (i) < (occ.size()); (i)++) {
    cur = min(cur / 2, occ[i]);
    if (cur == 0) break;
    best = max(best, ((1 << (i + 1)) - 1) * cur);
  }
  cout << best << endl;
  return 0;
}
