#include <bits/stdc++.h>
using namespace std;
const long long maxx = 200006;
const long long mod = 1000000000 + 7;
const long long INF = 1e18;
int ans = 10000000;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<int, int> m;
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    m[x]++;
  }
  vector<int> v;
  for (auto to : m) v.push_back(to.second);
  sort(v.begin(), v.end());
  int nn = v.size(), ans = 0;
  for (int i = 1; i <= v.back(); i++) {
    int curr = i, j = nn - 1, sum = curr;
    while (j > 0 && curr % 2 == 0) {
      j--;
      curr /= 2;
      if (v[j] >= curr)
        sum += curr;
      else
        break;
    }
    ans = max(ans, sum);
  }
  cout << ans;
}
