#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
vector<int> vec;
int check(int x) {
  int ret = 0;
  int last = 0;
  while (true) {
    int tmp =
        (int)(lower_bound(vec.begin() + last, vec.end(), x) - vec.begin());
    if (tmp == vec.size())
      break;
    else
      ret += x;
    last = tmp + 1;
    x <<= 1;
  }
  return ret;
}
int main() {
  int n, tmp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    mp[tmp]++;
  }
  for (auto x : mp) {
    vec.push_back(x.second);
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, check(i));
  }
  cout << ans << endl;
}
