#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, k, l, x;
  map<long long, long long> mp;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    mp[x]++;
  }
  vector<long long> v;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  long long mx = 0;
  long long tmp = 0;
  for (i = 1; i <= n; i++) {
    tmp = i;
    ans = 0;
    auto it1 = v.begin();
    while (1) {
      auto it = lower_bound(it1, v.end(), tmp);
      if (it != v.end()) {
        ans += tmp;
      } else
        break;
      it1 = ++it;
      tmp = tmp * (2LL);
    }
    mx = max(ans, mx);
  }
  cout << mx << endl;
}
