#include <bits/stdc++.h>
using namespace std;
int arr[200010];
vector<int> hashArr;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  sort(arr, arr + n);
  int index = 0, prev = -1, sz = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != prev) {
      prev = arr[i];
      if (sz != 0) {
        hashArr.push_back(sz);
      }
      sz = 1;
      index++;
    } else {
      sz++;
    }
  }
  hashArr.push_back(sz);
  sort(hashArr.begin(), hashArr.end());
  int maxx = hashArr[hashArr.size() - 1];
  int szz = hashArr.size();
  int maxAns = 0;
  for (int i = 1; i <= maxx; i++) {
    int curAns = 0;
    int f = i;
    vector<int>::iterator diff = lower_bound(hashArr.begin(), hashArr.end(), f);
    while (diff != hashArr.end()) {
      curAns += f;
      f = f * 2;
      diff++;
      vector<int>::iterator diff2 = lower_bound(diff, hashArr.end(), f);
      diff = diff2;
    }
    maxAns = max(maxAns, curAns);
  }
  cout << maxAns << endl;
  return 0;
}
