#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int M = 1e9 + 7;
int a[N], b[N], c[N], d[N];
map<int, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0, x;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (!mp[x]) {
      mp[x] = ++cnt;
    }
    ++a[mp[x]];
  }
  sort(a + 1, a + cnt + 1);
  int ans = 0;
  for (int j = 1; j <= n; ++j) {
    int m = 0;
    int la = 1;
    for (int k = j; k <= n; k *= 2) {
      int pos = lower_bound(a + la, a + cnt + 1, k) - a;
      if (pos == cnt + 1) break;
      m += k;
      la = pos + 1;
    }
    ans = max(ans, m);
  }
  printf("%d\n", ans);
  return 0;
}
