#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
set<int> s[200100];
int main() {
  int n, i, j, k, x, y, ans = 0, curr, maxi = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &curr);
    mp[curr]++;
    maxi = max(maxi, mp[curr]);
    s[mp[curr]].insert(curr);
  }
  int cek, sum;
  for (i = 200000; i >= 1; i--) {
    cek = 0;
    sum = 0;
    j = i;
    while (1) {
      if (s[j].size() - cek < 1)
        break;
      else {
        sum += j;
        if (j % 2 == 1) break;
        j /= 2;
        cek++;
      }
    }
    ans = max(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}
