#include <bits/stdc++.h>
using namespace std;
void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
const int N = 2 * (int)1e5 + 10;
int n, a[N], hm[N], hhm[N];
map<int, int> ile;
vector<int> v;
bool niedasie(int i, int len) {
  int cur = hm[i];
  for (int j = i; j < i + len; ++j) {
    if (hhm[j] < cur) return true;
    cur *= 2;
  }
  return false;
}
int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ++ile[a[i]];
  }
  for (int i = 1; i <= n; ++i) {
    if (ile[a[i]] == 0) continue;
    v.push_back(ile[a[i]]);
    ile[a[i]] = 0;
  }
  sort(v.begin(), v.end());
  int res = 0;
  for (int i = 0; i < v.size(); ++i) {
    hm[i] = v[i];
    hhm[i] = v[i];
  }
  for (int len = 1; len < 19; ++len)
    for (int i = 0; i < v.size(); ++i) {
      while (hm[i] > 0 && niedasie(i, len)) --hm[i];
      if (hm[i] == 0) continue;
      res = max(res, ((1 << len) - 1) * hm[i]);
    }
  cout << res << "\n";
}
