#include <bits/stdc++.h>
using namespace std;
vector<long long> arr;
long long val[200000];
int main() {
  int n;
  cin >> n;
  map<long long, long long> mp;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    mp[a]++;
  }
  for (auto i : mp) {
    arr.push_back(i.second);
  }
  sort(arr.begin(), arr.end());
  long long ans = arr[arr.size() - 1];
  val[arr.size() - 1] = ans;
  for (int i = arr.size() - 2; i >= 0; i--) {
    val[i] = min(val[i + 1] / 2, arr[i]);
    long long sum = val[i] * ((1 << (arr.size() - i)) - 1);
    ans = max(ans, sum);
  }
  cout << ans;
  return 0;
}
