#include <bits/stdc++.h>
using namespace std;
map<int, int> cnt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    cnt[t]++;
  }
  if (cnt.size() == 1) {
    cout << n << endl;
    return 0;
  }
  vector<int> freq;
  for (auto &p : cnt) {
    freq.push_back(p.second);
  }
  sort(freq.begin(), freq.end());
  int m = int(freq.size());
  int ans = 0;
  for (int i = 1; i <= freq[m - 1]; ++i) {
    int p = m - 1;
    int res = i;
    int j = i;
    while (j % 2 == 0 and p > 0) {
      j /= 2;
      p--;
      if (freq[p] < j) break;
      res += j;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  42;
  return 0;
};
