#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<long long, int> m;
  for (int i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    ++m[a];
  }
  vector<int> f{};
  for (auto pr : m) {
    f.push_back(pr.second);
  }
  sort(f.begin(), f.end());
  int t = (int)f.size();
  int recordtotal = 1;
  for (int d = 1; d <= n; ++d) {
    int tot = 0;
    int needednow = d;
    int j = 0;
    while (j < t) {
      auto it = lower_bound(f.begin() + j, f.end(), needednow);
      j = (int)(it - f.begin());
      if (j < t) {
        tot += needednow;
      }
      needednow *= 2;
      ++j;
    }
    recordtotal = max(recordtotal, tot);
  }
  cout << recordtotal << el;
}
