#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, c = getchar(), f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  return f ? -x : x;
}
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
int a[maxn];
int n, k;
map<int, int> vis;
int main() {
  n = read();
  k = 0;
  for (int i = 1; i <= n; i++) {
    int x = read();
    if (vis[x] == 0) vis[x] = ++k;
    a[vis[x]]++;
  }
  sort(a + 1, a + k + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = i, temp = 0, y = 0;
    while (true) {
      int id = lower_bound(a + y + 1, a + k + 1, x) - a;
      if (id == k + 1) break;
      temp += x;
      x *= 2;
      y = id;
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
