#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
void read_input() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
int main() {
  read_input();
  sort(begin(a), end(a));
  vector<int> lengths;
  int prev = -1;
  int len = 0;
  for (int val : a) {
    if (prev != val) {
      if (len != 0) lengths.push_back(len);
      prev = val;
      len = 1;
      continue;
    }
    len++;
  }
  lengths.push_back(len);
  sort(begin(lengths), end(lengths));
  int globalans = 0;
  for (int lenofcontest = 1; lenofcontest < 200001; lenofcontest++) {
    int tmp = lenofcontest;
    int ptr = 0;
    int localans = 0;
    while (ptr < lengths.size()) {
      if (lenofcontest > 200000) break;
      ptr = lower_bound(begin(lengths) + ptr, end(lengths), lenofcontest) -
            begin(lengths);
      if (ptr >= lengths.size()) break;
      if (lenofcontest <= lengths[ptr]) {
        localans += lenofcontest;
        lenofcontest *= 2;
      }
      ptr++;
    }
    globalans = max(globalans, localans);
    lenofcontest = tmp;
  }
  cout << globalans << endl;
}
