#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], freq[N];
map<int, int> comp;
vector<int> v;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    comp[a[i]] = 0;
  }
  int idx = 0;
  for (auto &x : comp) x.second = idx++;
  for (int i = 0; i < n; i++) {
    freq[comp[a[i]]]++;
  }
  for (int i = 0; i < N; i++) {
    if (freq[i]) {
      v.push_back(freq[i]);
    }
  }
  sort(v.begin(), v.end());
  int mx = 0, prev = 0;
  for (int i = 1; i <= v[v.size() - 1]; i++) {
    int temp = 0;
    prev = 0;
    for (int j = 0, x = i; j < idx && x <= v[v.size() - 1]; j++, x *= 2) {
      int it = lower_bound(v.begin() + prev, v.end(), x) - v.begin();
      if (it != v.size()) {
        temp += x;
        prev = it + 1;
      }
    }
    mx = max(mx, temp);
  }
  printf("%d", mx);
  return 0;
}
