#include <bits/stdc++.h>
using namespace std;
int n, a[200000 + 1], pos, cur, ans = 0, res;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  v.push_back(1);
  for (int i = 2; i <= n; i++) {
    if (a[i] != a[i - 1])
      v.push_back(1);
    else
      v.back()++;
  }
  sort(v.begin(), v.end());
  for (int i = 1; i <= v.back(); i++) {
    res = i;
    cur = i;
    pos = v.size() - 1;
    while (cur % 2 == 0 && pos > 0) {
      pos--;
      cur /= 2;
      if (v[pos] < cur) break;
      res += cur;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}
