#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2e5 + 10;
const long long INF = 1e18;
const long long MOD = 998244353;
int main() {
  int n, i, j, k, l, p, q, x, y;
  cin >> n;
  int a[n];
  map<int, int> mp, mp1, mp2;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  set<int> s, s1;
  for (auto x : mp) {
    s1.insert(x.second);
    mp1[x.second]++;
  }
  l = 0;
  for (i = 1; i <= n; i++) {
    s.clear();
    mp2.clear();
    auto z = s1.lower_bound(i);
    if (z == s1.end())
      continue;
    else {
      y = *z;
      mp2[y]++;
      if (mp1[y] == mp2[y]) {
        s1.erase(y);
        s.insert(y);
      }
    }
    p = i;
    j = i * 2;
    while (true) {
      auto z = s1.lower_bound(j);
      if (z == s1.end())
        break;
      else {
        p += j;
        j = j * 2;
        y = *z;
        mp2[y]++;
        if (mp1[y] == mp2[y]) {
          s1.erase(y);
          s.insert(y);
        }
      }
    }
    l = max(l, p);
    s1.insert(s.begin(), s.end());
  }
  cout << l << "\n";
}
