#include <bits/stdc++.h>
using namespace std;
map<long long, int> vis;
long long a[300000];
vector<int> v;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    vis[a[i]]++;
  }
  for (auto it = vis.begin(); it != vis.end(); it++) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end());
  long long ans = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    int c = lower_bound(v.begin(), v.end(), i) - v.begin();
    if (c == v.size()) break;
    sum += i;
    int y = i, j = c;
    while (1) {
      int x = lower_bound(v.begin() + j, v.end(), 2 * y) - v.begin();
      if (x == v.size()) break;
      if (x == j) {
        if (x == v.size() - 1) break;
        sum += 2 * y;
        y *= 2;
        j = j + 1;
      } else {
        j = x;
        sum += y * 2;
        y *= 2;
      }
    }
    ans = max(ans, sum);
    sum = 0;
  }
  cout << ans;
  return 0;
}
