#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 100;
int t, n, k;
int a[N], X[N];
bool BS(int x) {
  int l = 1;
  int r = n;
  int mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (X[mid] < x)
      l = mid + 1;
    else {
      r = mid - 1;
      return 1;
    }
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  X[1] = 1;
  int cnt = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] != a[i])
      X[++cnt] = 1;
    else
      X[cnt]++;
  }
  sort(X + 1, X + cnt + 1);
  int ans = 1, flag = 1, d = X[1];
  for (int i = 1; i <= cnt; i++) {
    for (int j = 1; j <= X[i]; j++) {
      flag = 1;
      int tmp = j;
      int find = lower_bound(X + i + 1, X + cnt + 1, 2 * tmp) - X;
      ;
      while (find <= cnt) {
        flag++;
        tmp *= 2;
        find = lower_bound(X + find + 1, X + cnt + 1, 2 * tmp) - X;
      }
      int temp = j * (pow(2, flag) - 1);
      ans = max(ans, temp);
    }
  }
  cout << ans << endl;
  return 0;
}
