#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int oo = 1e9 + 5;
const int LOG = 30;
int n, top, A[N];
long long pw[LOG + 5], cnt[N];
void init() {
  pw[0] = 1;
  for (int i = (1); i <= (LOG); i++) pw[i] = pw[i - 1] * 2;
}
long long get(int num) {
  long long mi = oo;
  for (int i = (1); i <= (num); i++) {
    mi = min(mi, cnt[i] / pw[num - i]);
  };
  return mi;
}
int main() {
  cin >> n;
  for (int i = 0, _n = (n); i < _n; i++) scanf("%d", A + i);
  sort(A, A + n);
  for (int i = 0, _n = (n); i < _n; i++) {
    if (i == 0 || A[i] != A[i - 1])
      cnt[++top] = 1;
    else
      cnt[top]++;
  }
  sort(cnt + 1, cnt + top + 1, greater<int>());
  init();
  long long ans = 0;
  for (int i = (1); i <= (LOG); i++) {
    long long t = get(i);
    { ans = max(ans, (pw[i - 1] * 2 - 1) * t); };
  }
  cout << ans;
}
