#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> dif;
map<int, int> cnt;
vector<int> cur;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
    if (cnt[x] == 1) dif.push_back(x);
  }
  for (int i = 0; i < dif.size(); i++) {
    cur.push_back(cnt[dif[i]]);
  }
  sort(cur.begin(), cur.end());
  reverse(cur.begin(), cur.end());
  while (cur.size() > 18) cur.pop_back();
  reverse(cur.begin(), cur.end());
  int pan = cur.size();
  int ans = 0;
  for (int i = 1; i < (1 << pan); i++) {
    int mi = 1e6;
    int tmp = 1;
    int itu = 0;
    for (int j = 0; j < pan; j++) {
      if ((1 << j) & i) {
        mi = min(mi, cur[j] / tmp);
        tmp *= 2;
        itu++;
      }
    }
    ans = max(ans, mi * ((1 << itu) - 1));
  }
  printf("%d\n", ans);
  return 0;
}
