#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
const int lim = 1e6 + 7;
int suffix[lim], n, ip, ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ip;
    m[ip]++;
  }
  for (auto u : m) suffix[u.second]++;
  for (int i = lim - 2; i >= 0; i--) suffix[i] += suffix[i + 1];
  for (int i = 1; i <= n; i++) {
    int need = 0, val = 0;
    for (int j = i;; j *= 2) {
      need++;
      int taken = min(need, suffix[j] - suffix[2 * j]);
      need -= taken;
      if (need <= suffix[2 * j])
        val += j;
      else
        break;
    }
    ans = max(ans, val);
  }
  cout << ans;
  return 0;
}
