#include <bits/stdc++.h>
using namespace std;
long long int solve(vector<long long int> &v, long long int x,
                    long long int n) {
  long long int ans = 0;
  long long int last = -1;
  while (true) {
    auto it = upper_bound(v.begin(), v.end(), x);
    if (it != v.begin() && *prev(it) == x) --it;
    long long int pos = it - v.begin();
    pos = max(pos, last + 1);
    if (pos >= n) break;
    ans += x;
    last = pos;
    x *= 2;
  }
  return ans;
}
void mainSolve() {
  long long int n;
  cin >> n;
  vector<long long int> inp(n);
  for (long long int i = 0; i < n; i++) cin >> inp[i];
  ;
  map<long long int, long long int> m;
  for (int x : inp) m[x]++;
  vector<long long int> v;
  for (auto it : m) v.push_back(it.second);
  n = v.size();
  long long int ans = 0;
  sort(v.begin(), v.end());
  long long int mx = v[n - 1];
  for (int i = 1; i <= v[n - 1]; i++) {
    ans = max(ans, solve(v, i, n));
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    mainSolve();
  }
  return 0;
}
