#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> arr;
  map<long long, long long> mapa;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    mapa[a]++;
  }
  for (auto p : mapa) {
    arr.push_back(p.second);
  }
  sort(arr.begin(), arr.end());
  vector<long long> a(arr.size() + 1);
  a[1] = arr[arr.size() - 1];
  long long ans = a[1];
  long long mn = 3;
  for (int i = 2; i <= arr.size(); i++) {
    a[i] = min(a[i - 1] / 2, arr[arr.size() - i]);
    ans = max(ans, a[i] * mn);
    mn = (mn + 1) * 2 - 1;
  }
  cout << ans;
  return 0;
}
