#include <bits/stdc++.h>
using namespace std;
const int N = 1000007, inf = 0x3f3f3f3f;
map<int, int> cnt;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  vector<int> v;
  for (pair<int, int> x : cnt) {
    v.push_back(x.second);
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    long long tot = 0;
    long long x = i;
    int cur = lower_bound(v.begin(), v.end(), x) - v.begin();
    while (cur < v.size()) {
      tot += x;
      x *= 2ll;
      cur = lower_bound(v.begin() + cur + 1, v.end(), x) - v.begin();
    }
    ans = max(ans, tot);
  }
  cout << ans << endl;
}
