#include <bits/stdc++.h>
using namespace std;
int compare_int(int A, int B) { return A - B; }
int N;
vector<int> A;
int S[200005][20];
int M[200005][20];
int bestS[20];
int bestM[20];
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A.push_back(x);
  }
  sort(A.begin(), A.end());
  int distinct = 0;
  int prev = -1;
  for (int i = 0; i < N; i++) {
    if (A[i] == prev) {
      A[i] = distinct - 1;
    } else {
      prev = A[i];
      distinct += 1;
      A[i] = distinct - 1;
    }
  }
  vector<int> count;
  for (int i = 0; i < distinct; i++) count.push_back(0);
  for (int i = 0; i < N; i++) count[A[i]]++;
  sort(count.begin(), count.end());
  int answer = 0;
  for (int i = 0; i < distinct; i++) {
    int pot = 524288;
    for (int j = 20 - 1; j >= 1; j--) {
      int c = count[i] / pot;
      if (c > bestM[j - 1]) c = bestM[j - 1];
      if (bestM[j] < c) {
        bestM[j] = c;
      }
      int score = (pot * 2 - 1) * c;
      if (answer < score) {
        answer = score;
      }
      pot /= 2;
    }
    if (bestM[0] < count[i]) {
      bestM[0] = count[i];
    }
    if (answer < count[i]) {
      answer = count[i];
    }
    if (false)
      for (int j = 0; j < 20; j++) {
        cout << "bestM[" << i << "][" << j << "] = " << bestM[j] << endl;
      }
  }
  cout << answer << endl;
}
