#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    mp[a]++;
  }
  vector<int> nums;
  for (auto p : mp) nums.push_back(p.second);
  sort(nums.rbegin(), nums.rend());
  int ans = 0, mn = 1e9;
  for (int i = 0; i < nums.size(); i++) {
    mn = min(mn / 2, nums[i]);
    if (mn == 0) break;
    int result = mn * (pow(2, i + 1) - 1);
    ans = max(ans, result);
  }
  cout << ans << endl;
  return 0;
}
