#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
map<int, int> mp;
int a[maxn * 2];
bool cmp(int x, int y) { return x > y; }
bool cmp2(int x, int y) { return x < y; }
int main() {
  int n;
  cin >> n;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (mp[x] == 0) {
      mp[x] = cnt;
      cnt++;
    }
    a[mp[x]]++;
  }
  sort(a, a + 2 * maxn, cmp);
  int m;
  for (int i = 0; i < 2 * maxn; i++) {
    if (a[i] == 0) {
      m = i;
      break;
    }
  }
  sort(a, a + m, cmp2);
  long long ans = 0;
  int qian = 0;
  for (int i = 1; i <= a[m - 1]; i++) {
    long long all = 0;
    long long k = i;
    long long l = 0;
    while (1) {
      long long z = lower_bound(a + l, a + m, k) - a;
      if (z == m) break;
      all += k;
      k = k * 2;
      l = z + 1;
    }
    ans = max(all, ans);
  }
  cout << ans << endl;
}
