#include <bits/stdc++.h>
using namespace std;
void mainSolve() {
  int n;
  cin >> n;
  vector<int> inp(n);
  for (int i = 0; i < n; i++) cin >> inp[i];
  map<int, int> m;
  for (int x : inp) m[x]++;
  vector<long long int> v;
  for (auto it : m) v.push_back(it.second);
  n = v.size();
  sort(v.begin(), v.end());
  int mx = v[n - 1];
  int ans = mx;
  for (int i = 2; i <= mx; i += 2) {
    int x = i;
    int pos = n - 1;
    int curr = x;
    while (x % 2 == 0 && pos > 0) {
      x /= 2;
      --pos;
      if (v[pos] < x) break;
      curr += x;
    }
    ans = max(ans, curr);
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    mainSolve();
  }
  return 0;
}
