#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a, b;
int x, y;
int T, t;
int ans = 0;
string str;
int arr[((int)2e5 + 10)];
map<int, int> mp;
int len = 0;
int MAX = -1;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t);
    mp[t]++;
  }
  map<int, int>::iterator iter = mp.begin();
  while (iter != mp.end()) {
    arr[++len] = iter->second;
    iter++;
  }
  sort(arr + 1, arr + 1 + len);
  int l = 1, r = n, xx = 1;
  for (int i = 1; i <= n; i++) {
    k = i;
    int sum = 0;
    int l = 1;
    for (int j = 1; j <= len && k <= n; j++) {
      int pos = lower_bound(arr + l, arr + 1 + len, k) - arr;
      if (pos != len + 1) {
        sum += k;
        l = pos + 1;
        k *= 2;
      } else
        break;
    }
    ans = max(ans, sum);
  }
  cout << ans << '\n';
}
