#include <bits/stdc++.h>
using namespace std;
long long a2[55], b[int(2e5 + 5)], cnt;
map<long long, long long> m;
int main() {
  long long n, i, j;
  a2[0] = 1;
  for (i = 1; i <= 50; i++) {
    a2[i] = a2[i - 1] * 2;
  }
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%lld", &j);
    m[j]++;
  }
  map<long long, long long>::iterator it;
  for (it = m.begin(); it != m.end(); it++) {
    b[cnt++] = it->second;
  }
  sort(b, b + cnt);
  long long sum = b[cnt - 1];
  long long mid = sum, p = cnt - 2;
  while (mid && p >= 0) {
    mid /= 2;
    if (b[p] >= mid) {
      sum = max(sum, mid * (a2[cnt - p] - 1));
    } else {
      mid = b[p];
      sum = max(sum, mid * (a2[cnt - p] - 1));
    }
    p--;
  }
  cout << sum << endl;
}
