#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323;
long long mod = 1000000000 + 7;
long long modu = 998244353;
const long double pii = acos(-1.0);
const long long INF = 1e18;
const long long inf = 1e9;
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long powe(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long ncr(long long n, long long r) {
  long long res = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
void fun() {}
const long long N = 1e6 + 7;
std::vector<long long> v;
unordered_map<long long, long long> m;
long long mila_kya(long long l, long long r, long long x) {
  long long lo = l, hi = r, res = -1;
  while (hi >= lo) {
    long long mid = (hi + lo) >> 1;
    if (v[mid] >= x) {
      hi = mid - 1;
      res = mid;
    } else
      lo = mid + 1;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  fun();
  long long ttt = 1;
  while (ttt--) {
    long long n;
    cin >> n;
    long long a[n + 1];
    for (long long i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long c = 1;
    a[n] = -1;
    for (long long i = 0; i < n; i++) {
      if (a[i] == a[i + 1])
        c++;
      else
        v.push_back(c), c = 1;
    }
    sort(v.begin(), v.end());
    long long ans = v[(long long)(v.size()) - 1];
    long long size = (long long)(v.size());
    for (long long i = 1; i <= ans; i++) {
      long long kaha_se = mila_kya(0, size - 1, i);
      if (kaha_se < 0) continue;
      long long res = i, need = i;
      while (1) {
        need *= 2;
        kaha_se = mila_kya(kaha_se + 1, size - 1, need);
        if (kaha_se < 0) break;
        res += need;
      }
      ans = max(ans, res);
    }
    cout << ans << "\n";
  }
  return 0;
}
