#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<int, int> mp, mpp;
  vector<int> a(n);
  int ma = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (auto it : mp) {
    ma = max(ma, it.second);
    mpp[it.second]++;
  }
  int ans = 0;
  for (int i = 1; i < ma + 1; i++) {
    int cnt = 0, cur = i;
    map<int, int> tmp = mpp;
    while (1) {
      auto it = tmp.lower_bound(cur);
      if (it == tmp.end())
        break;
      else {
        (*it).second--;
        if ((*it).second == 0) {
          tmp.erase(it);
        }
        cnt += cur;
        cur *= 2;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
