#include <bits/stdc++.h>
using namespace std;
const long long oo = 0x3f3f3f3f;
const long long OO = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int tc = 1;
  while (tc--) {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    multiset<int> ms;
    ms.insert(oo);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }
    for (auto it : mp) {
      ms.insert(it.second);
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
      long long x = i;
      multiset<int> t;
      long long sum = 0;
      while (true) {
        int it = *ms.lower_bound(x);
        if (it == oo) break;
        t.insert(it);
        ms.erase(ms.find(it));
        sum += x;
        ans = max(ans, sum);
        x += x;
      }
      for (int it : t) ms.insert(it);
    }
    cout << ans << "\n";
  }
}
