#include <bits/stdc++.h>
using namespace std;
int t[200001], occ[200001];
map<int, int> m;
vector<pair<int, int> > fin;
long long i, n, br = 0, l = 0, k, otg = 0, j, sum = 0;
int binary(int _l, int _r, int val) {
  int l = _l, r = _r, mid, a = -1;
  while (l <= r) {
    mid = (l + r) / 2;
    if (fin[mid].first >= val) {
      a = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int i, n;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t[i];
    m[t[i]]++;
    if (m[t[i]] == 1) {
      occ[l] = t[i];
      l++;
    }
  }
  for (i = 0; i < l; i++) {
    fin.push_back(make_pair(m[occ[i]], occ[i]));
  }
  sort(fin.begin(), fin.end());
  int maks = fin[l - 1].first;
  for (i = 1; i <= maks; i++) {
    sum = 0;
    br = i;
    j = 0;
    while (j < l) {
      j = binary(j, fin.size() - 1, br);
      if (j == -1) break;
      sum += br;
      br *= 2;
      j++;
    }
    if (sum > otg) otg = sum;
  }
  cout << otg << endl;
  return 0;
}
