#include <bits/stdc++.h>
using namespace std;
int n, x, y, k, ans, a[200050], u;
map<int, int> my;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> x, my[x]++;
  map<int, int>::iterator it = my.begin();
  for (; it != my.end(); ++it) a[k++] = it->second;
  sort(a, a + k + 1);
  for (int i = 1; i <= k; ++i) {
    for (int j = a[i - 1] + 1; j <= a[i]; ++j) {
      x = j;
      u = 0;
      y = i;
      while (x <= a[k] && y < k + 1) {
        y += 1;
        u += x;
        x <<= 1;
        y = lower_bound(a + y, a + k + 1, x) - a;
      }
      if (u > ans) ans = u;
    }
  }
  cout << ans;
  return 0;
}
