#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0;
  cin >> n;
  map<int, int> amaa;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    amaa[a]++;
  }
  vector<int> am;
  for (auto& x : amaa) am.push_back(x.second);
  sort((am).rbegin(), (am).rend());
  int l = 0, cur = 0;
  cur = am[0];
  l = 1;
  int ans = cur;
  for (int i = 1; i < am.size(); i++) {
    cur = min(cur / 2, am[i]);
    if (cur == 0) break;
    l++;
    int cans = 0;
    for (int xx = 0; xx < l; xx++) cans += (cur << xx);
    ans = max(ans, cans);
  }
  cout << ans;
  return 0;
}
