#include <bits/stdc++.h>
using namespace std;
const int MAX = 200 * 1000 + 1;
int main() {
  int n;
  cin >> n;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    m[t]++;
  }
  vector<int> cnt;
  for (auto it : m) {
    cnt.push_back(it.second);
  }
  sort(cnt.begin(), cnt.end());
  int ans = 0;
  for (int i = 1; i <= cnt.back(); i++) {
    int pos = cnt.size() - 1;
    int cur = i;
    int res = cur;
    while (cur % 2 == 0 && pos > 0) {
      cur /= 2;
      pos--;
      if (cnt[pos] < cur) break;
      res += cur;
    }
    ans = max(ans, res);
  }
  cout << ans << '\n';
  return 0;
}
