#include <bits/stdc++.h>
using namespace std;
int a[200001], b[200001];
map<int, int> num;
bool cmp(int x, int y) {
  if (x == 0) return false;
  return x < y;
}
int fin(int x, int l, int r) {
  while (l < r) {
    int mid = (l + r) >> 1;
    if (b[mid] >= x)
      r = mid;
    else
      l = mid + 1;
  }
  return r;
}
int main() {
  int n;
  int i, j, k;
  int top = 0, ans, sum;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (num[a[i]] == 0) {
      top++;
      num[a[i]] = top;
    }
    b[num[a[i]]]++;
  }
  sort(b + 1, b + top + 1, cmp);
  ans = 0;
  for (i = 1; i <= n; i++) {
    sum = 0;
    k = 0;
    for (j = i;; j *= 2) {
      if (j > b[top]) break;
      if (k + 1 > top) break;
      k = fin(j, k + 1, top);
      sum += j;
    }
    ans = max(ans, sum);
  }
  cout << ans;
}
