#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int n, a[maxn], tot, b[maxn], ans;
inline int read() {
  int ret = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * f;
}
inline int BinarySearch(int l, int x) {
  int L = l, R = tot, mid;
  while (L <= R) {
    mid = L + R >> 1;
    b[mid] >= x ? R = mid - 1 : L = mid + 1;
  }
  return L;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + 1 + n);
  int cnt = 1;
  for (int i = 2; i <= n + 1; i++) {
    if (a[i] != a[i - 1]) {
      b[++tot] = cnt;
      cnt = 1;
    } else
      cnt++;
  }
  sort(b + 1, b + 1 + tot);
  for (int i = 1; i <= tot; i++) {
    for (int j = b[i - 1] + 1; j <= b[i]; j++) {
      int now = j, lst = j, ret = BinarySearch(i + 1, 2 * lst);
      while (ret <= tot) {
        lst *= 2;
        now += lst;
        ret = BinarySearch(ret + 1, 2 * lst);
      }
      if (now > ans) ans = now;
    }
  }
  printf("%d\n", ans);
  return 0;
}
