#include <bits/stdc++.h>
using namespace std;
;
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
int n, sz;
long long ans;
int a[maxn], num[maxn];
vector<int> v;
bool check(int x) {
  int tmp = x, tt = 0;
  long long sum = 0;
  while (1) {
    int pos = lower_bound(num + tt, num + sz, tmp) - num;
    if (pos >= sz) break;
    sum += tmp;
    tmp *= 2;
    tt = pos + 1;
  }
  int flag = 0;
  if (sum >= ans) {
    ans = sum;
    flag = 1;
  }
  return flag;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  sz = v.size();
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    num[a[i]]++;
  }
  sort(num, num + sz);
  int ub = num[sz - 1], lb = 0, mid;
  for (mid = 1; mid <= ub; mid++) {
    if (check(mid)) continue;
  }
  printf("%lld\n", ans);
  return 0;
}
