#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> problems(n);
  for (int i = 0; i < n; ++i) cin >> problems[i];
  sort(problems.begin(), problems.end());
  vector<int> themes;
  int i = 0;
  int cur_th = problems[0];
  int cur = 0;
  while (i < n) {
    if (cur_th != problems[i]) {
      themes.push_back(cur);
      cur = 0;
      cur_th = problems[i];
      ;
    }
    ++i;
    ++cur;
  }
  if (cur != 0) themes.push_back(cur);
  sort(themes.begin(), themes.end());
  int maximum = 0;
  for (int i = 1; i <= themes.back(); ++i) {
    int current, sum;
    current = i, sum = current;
    int pointer = themes.size() - 1;
    while (pointer > 0 && current % 2 == 0) {
      current /= 2;
      --pointer;
      if (themes[pointer] < current) break;
      sum += current;
    }
    if (sum > maximum) maximum = sum;
  }
  cout << maximum << '\n';
}
