#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) m[v[i]]++;
  vector<long long> ans;
  for (long long i = 0; i < n; i++) {
    if (m[v[i]] != 0) {
      ans.push_back(m[v[i]]);
      m[v[i]] = 0;
    }
  }
  sort(ans.begin(), ans.end());
  long long ans1 = 0;
  for (long long i = 1; i <= n; i++) {
    long long mx = 0;
    long long val = i;
    long long ind = 0;
    while (1) {
      auto it = lower_bound(ans.begin() + ind, ans.end(), val);
      if (it == ans.end()) break;
      long long tmp = it - ans.begin();
      ind = tmp + 1;
      mx += val;
      val *= 2;
    }
    ans1 = max(ans1, mx);
  }
  cout << ans1;
}
