#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  vector<int> times;
  for (auto x : a) {
    times.push_back(x.second);
  }
  sort(times.begin(), times.end());
  int size_times_idx = times.size() - 1;
  int maxx = -1;
  for (int i = size_times_idx; i > 0; i--) {
    for (int j = times[i]; j >= 1; j--) {
      int cnt = j;
      int pos = i;
      int sum = j;
      while (cnt % 2 == 0 && pos > 0) {
        cnt /= 2;
        if (cnt > times[--pos]) {
          break;
        }
        sum += cnt;
      }
      maxx = max(sum, maxx);
    }
  }
  if (times.size() == 1) {
    cout << times[0] << endl;
  } else {
    cout << maxx << endl;
  }
  return 0;
}
