#include <bits/stdc++.h>
using namespace std;
int a[200010], b[200010];
map<int, int> m;
bool cmp(int a, int b);
int main() {
  memset(b, 0, sizeof(b));
  int n, i, j, k, ans, bf, maxx = -1, num = 1;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (m[a[i]] == 0) m[a[i]] = num, num += 1;
    b[m[a[i]]]++;
  }
  sort(b + 1, b + num, cmp);
  for (i = 1; i < num; i++) {
    for (j = 1; j <= b[i]; j++) {
      ans = j;
      bf = j * 2;
      for (k = i + 1; k < num; k++)
        if (b[k] >= bf) {
          ans += bf;
          bf *= 2;
        } else
          break;
      maxx = max(ans, maxx);
    }
  }
  printf("%d\n", maxx);
  return 0;
}
bool cmp(int a, int b) { return a < b; }
