#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O2")
const int LIM = 5e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y;
map<int, int> f;
vector<int> freq;
int start[LIM];
int arr[LIM];
long long ans = 0;
void process() {
  for (int i = 1; i <= 2e5; i++) {
    auto it = lower_bound(freq.begin(), freq.end(), i);
    if (it != freq.end()) {
      int index = it - freq.begin();
      long long curr = i;
      long long next = curr * 2;
      while (lower_bound(freq.begin(), freq.end(), next) != freq.end()) {
        int next_index =
            lower_bound(freq.begin(), freq.end(), next) - freq.begin();
        if (next_index > index)
          index = next_index;
        else {
          index++;
        }
        if (index == freq.size()) break;
        curr += next;
        next *= 2;
      }
      if (curr > ans) ans = curr;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    f[arr[i]]++;
  }
  for (auto it = f.begin(); it != f.end(); it++) {
    freq.push_back((*it).second);
  }
  sort(freq.begin(), freq.end());
  process();
  cout << ans << "\n";
}
