#include <bits/stdc++.h>
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
FILE* out = stdout;
FILE* in = stdin;
const int MAXN = 200005;
int n, best, cur, s, A[MAXN];
vector<int> U;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  sort(A, A + n);
  U.push_back(1);
  for (int i = 1; i < n; i++) {
    if (A[i] == A[i - 1]) {
      U.back()++;
    } else {
      U.push_back(1);
    }
  }
  sort(U.begin(), U.end(), greater<int>());
  U.resize(min(20, ((int)(U).size())));
  reverse(U.begin(), U.end());
  for (int i = 1; i <= n; i++) {
    cur = 0;
    s = i;
    for (int j = 0; j < ((int)(U).size()); j++) {
      if (U[j] >= s) {
        cur += s;
        s = 2 * s;
      }
    }
    best = max(best, cur);
  }
  printf("%d\n", best);
  return 0;
}
