#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long n) {
  if (n == 1) return a;
  if (n == 0) return 1;
  if (n & 1) return a * power(a * a, n >> 1);
  return power(a * a, n >> 1);
}
map<long long, long long> mp;
vector<long long> v;
long long solve(long long x) {
  long long tot = 0, pid = -1;
  while (true) {
    long long id = lower_bound(v.begin(), v.end(), x) - v.begin();
    if (id == (long long)v.size()) break;
    if (id <= pid) {
      pid++;
      if (pid == (long long)v.size()) break;
    } else
      pid = id;
    tot += x;
    x *= 2;
  }
  return tot;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i < n + 1; ++i) {
    long long x;
    cin >> x;
    mp[x]++;
  }
  for (auto &it : mp) {
    v.push_back(it.second);
  }
  sort(v.begin(), v.end());
  long long ans = 1;
  for (long long i = 1; i < 200001; ++i) {
    ans = max(ans, solve(i));
  }
  cout << ans << "\n";
  return 0;
}
