#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
const int oo = 1e9 + 5;
int du[] = {-1, 0, 0, 1};
int dv[] = {0, -1, 1, 0};
const long long mod = 1e9 + 7;
long long sqr(long long x) { return x * x; }
int n, a[N + 5], res;
vector<int> q;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int num = 1;
  for (int i = 2; i <= n + 1; i++)
    if (a[i] != a[i - 1]) {
      q.push_back(num);
      num = 1;
    } else
      num++;
  sort(q.begin(), q.end());
  for (int i = 1; i <= q.back(); i++) {
    int vt = q.size() - 1;
    int cur = i;
    int sum = 0;
    while (vt >= 0 && q[vt] >= cur) {
      sum += cur;
      vt--;
      if (cur % 2 == 1)
        break;
      else
        cur /= 2;
    }
    res = max(res, sum);
  }
  cout << res;
  return 0;
}
