#include <bits/stdc++.h>
using namespace std;
int n, k, ans = 1;
int a[200005];
vector<int> v;
int get_max(int c) {
  int res = 0, id = 0;
  while (1) {
    id = lower_bound(v.begin() + id, v.end(), c) - v.begin();
    if (id == (int)v.size()) {
      break;
    }
    res += c;
    c *= 2;
    ++id;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int cnt = 1;
  for (int i = 0; i < n; ++i) {
    if (a[i] != a[i + 1]) {
      v.push_back(cnt);
      cnt = 1;
    } else {
      ++cnt;
    }
  }
  sort(v.begin(), v.end());
  for (int c = 1; c <= n; ++c) {
    ans = max(ans, get_max(c));
  }
  cout << ans;
}
