#include <bits/stdc++.h>
using namespace std;
int a[210100], s[200010], top, tp[210000], tot;
set<int> t;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n;) {
    int j = i;
    while (a[j] == a[i] && j <= n) j++;
    s[++top] = j - i;
    i = j;
  }
  sort(s + 1, s + top + 1);
  int ans = 0;
  for (int i = 1; i <= s[top]; i++) {
    int sum = 0, st = 1;
    for (int j = i;; j *= 2) {
      int p = lower_bound(s + st, s + top + 1, j) - s;
      if (p == top + 1) break;
      st = p + 1;
      sum += j;
    }
    if (sum > ans) ans = sum;
  }
  printf("%d", ans);
  return 0;
}
