#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
map<int, int> mp;
int a[maxn], n, m = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    mp[x]++;
  }
  for (auto v : mp) a[++m] = v.second;
  sort(a + 1, a + 1 + m);
  int ans = 0;
  for (int tp = 1; tp <= a[m]; ++tp) {
    int cur = tp, pos = m, res = tp;
    while (pos > 0 && cur % 2 == 0) {
      cur >>= 1;
      if (a[--pos] < cur) break;
      res += cur;
    }
    ans = max(ans, res);
  }
  printf("%d\n", ans);
  return 0;
}
