#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    int val;
    scanf("%d", &val);
    mp[val]++;
  }
  vector<int> vec;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++)
    vec.push_back(it->second);
  sort(vec.begin(), vec.end());
  int res = 0;
  for (int i = 1; i <= n; i++) {
    int now = i;
    int sum = 0;
    int idx = 0;
    while (true) {
      idx = lower_bound(vec.begin() + idx, vec.end(), now) - vec.begin();
      if (idx == vec.size()) break;
      sum += now;
      now *= 2;
      idx++;
    }
    res = max(res, sum);
  }
  printf("%d\n", res);
  return 0;
}
