#include <bits/stdc++.h>
int Inp() {
  char c = getchar();
  int Neg = 1;
  while (c < '0' || c > '9') {
    if (c == '-') Neg = -1;
    c = getchar();
  }
  int Sum = 0;
  while (c >= '0' && c <= '9') {
    Sum = ((Sum << 3) + (Sum << 1)) + c - '0';
    c = getchar();
  }
  return Neg * Sum;
}
std::map<int, int> ls;
int Cou[200010];
int s[200010];
int w[30];
int n;
bool Check(int Mid, int s) {
  int Cnt = 0;
  for (int i = 1; i <= n; i++)
    if (Cou[i] >= Mid) {
      Cnt++;
      Mid <<= 1;
    }
  return Cnt >= s;
}
int main() {
  n = Inp();
  int Cnt = 0;
  for (int i = 1; i <= n; i++) {
    s[i] = Inp();
    if (ls[s[i]] == 0)
      ;
    ls[s[i]] = ++Cnt;
  }
  for (int i = 1; i <= n; i++) Cou[ls[s[i]]]++;
  std::sort(Cou + 1, Cou + Cnt + 1);
  int Ans = 0;
  for (int i = 1; i <= 20; i++) {
    int l = 0;
    int r = 1e9;
    while (l < r) {
      int Mid = (l + r + 1) >> 1;
      if (Check(Mid, i))
        l = Mid;
      else
        r = Mid - 1;
    }
    Ans = std::max(Ans, l * ((1 << i) - 1));
  }
  printf("%d", Ans);
}
