#include <bits/stdc++.h>
using namespace std;
int N;
int A[202020];
map<int, int> M;
vector<int> V;
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  for (i = 0; i < (N); i++) cin >> x, M[x]++;
  for (auto& m : M) V.push_back(m.second);
  sort((V.begin()), (V.end()));
  int ma = 0;
  for (i = 1; i <= N; i++) {
    int sum = 0;
    j = i;
    int cur = 0;
    while (1) {
      y = lower_bound(V.begin() + cur, V.end(), j) - V.begin();
      if (y == V.size()) break;
      sum += j;
      j *= 2;
      cur = y + 1;
    }
    ma = max(ma, sum);
  }
  cout << ma << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
