#include <bits/stdc++.h>
using namespace std;
int N, arr[200001];
map<int, int> cnt;
vector<int> v;
int check(int cur) {
  int ans = 0, prev = 0;
  for (;;) {
    int pos = lower_bound(v.begin() + prev, v.end(), cur) - v.begin();
    if (pos >= 0 && pos < v.size()) {
      ans += cur;
      cur *= 2;
      prev = pos + 1;
    } else
      break;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    cnt[arr[i]]++;
  }
  for (map<int, int>::iterator it = cnt.begin(); it != cnt.end(); it++)
    v.push_back(it->second);
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 1; i <= N; i++) ans = max(ans, check(i));
  cout << ans << '\n';
  return 0;
}
