#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
map<int, int> mp;
int d2[N], d[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    mp[a[i]]++;
  }
  int l = 0;
  for (auto p : mp) {
    int t = p.second;
    d2[t]++;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= d2[i]; ++j) {
      d[++l] = i;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int tmp = 0;
    int st = 1;
    for (int j = i; j <= n; j = j * 2) {
      int t = lower_bound(d + st, d + l + 1, j) - d;
      if (t == l + 1) {
        break;
      } else {
        st = t + 1;
        tmp += j;
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
