#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> dp;
  map<int, int> dp2, dpp;
  for (int i = 0; i < n; i++) dp2[a[i]]++;
  for (auto i : dp2) {
    dp.push_back(i.second);
    dpp[i.second] = 1;
  }
  sort(dp.begin(), dp.end());
  int ans = 0;
  for (int mid = 1; mid <= n; mid++) {
    int m = mid;
    int temp = 0;
    int s = 0;
    while (1) {
      auto it = lower_bound(dp.begin() + s, dp.end(), m);
      if (it == dp.end()) {
        break;
      }
      s = it - dp.begin() + 1;
      temp += m;
      m = 2 * m;
    }
    ans = max(temp, ans);
  }
  cout << ans << '\n';
  return 0;
}
