#include <bits/stdc++.h>
using namespace std;
int h[1000001] = {0};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<int, int> d;
  int dp;
  for (int i = 0; i < n; i++) {
    cin >> dp;
    d[dp]++;
  }
  vector<int> s;
  for (auto i = d.begin(); i != d.end(); i++) {
    s.push_back(i->second);
  }
  sort(s.begin(), s.end(), greater<int>());
  dp = 0;
  for (int i = 1; i <= s[0]; i++) {
    int p = 0;
    int r = i, t = i;
    while (r % 2 == 0 && ++p < s.size()) {
      r /= 2;
      if (s[p] < r) break;
      t += r;
    }
    dp = max(dp, t);
  }
  cout << dp << endl;
  return 0;
}
