#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const double pi = acos(-1);
int main() {
  long long n;
  cin >> n;
  long long a[n];
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  vector<long long> v;
  for (auto itr : m) {
    v.push_back(itr.second);
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 1; i <= v.back(); i++) {
    long long pos = v.size() - 1;
    long long cur = i;
    long long ans1 = i;
    while (cur % 2 == 0 && pos > 0) {
      cur /= 2;
      pos--;
      if (v[pos] < cur) break;
      ans1 += cur;
    }
    ans = max(ans, ans1);
  }
  cout << ans << endl;
  return 0;
}
