#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int n;
long long int fun(int s) {
  int k = s;
  int i = 0;
  int ans = 0;
  auto it = v.begin();
  for (; k <= n;) {
    it = lower_bound(it, v.end(), k * ((int)pow(2, i)));
    if (it == v.end()) break;
    ans += k * ((int)pow(2, i));
    it++;
    i++;
  }
  return ans;
}
int main() {
  cin >> n;
  map<long long, int> m;
  for (int i = 1; i <= n; i++) {
    long long int x;
    cin >> x;
    m[x]++;
  }
  for (auto it = m.begin(); it != m.end(); it++) v.push_back(it->second);
  sort(v.begin(), v.end());
  long long int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, fun(i));
  cout << ans << "\n";
}
