#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 2e18;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
struct printer {
  ~printer() { cerr << endl; }
  template <class c>
  printer& operator,(c x) {
    cerr << boolalpha << x;
    return *this;
  }
  printer& operator,(string x) {
    cerr << x;
    return *this;
  }
  template <class c, class d>
  printer& operator,(pair<c, d> x) {
    return *this, "(", x.first, ", ", x.second, ")";
  }
  template <class... d, template <class...> class c>
  printer& operator,(c<d...> x) {
    return *this, range(begin(x), end(x));
  }
  template <class c>
  printer& operator,(rge<c> x) {
    *this, "[";
    for (auto it = x.b; it != x.e; ++it) *this, (it == x.b ? "" : ", "), *it;
    return *this, "]";
  }
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
const long long N = 2e5 + 10;
long long ar[N], dp[N], pw[N];
signed main() {
  pw[0] = 1;
  for (long long i = 1; i < N; i++) pw[i] = pw[i - 1] * 2;
  long long n;
  cin >> n;
  map<long long, long long> cnt;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    cnt[x]++;
  }
  long long idx = 0;
  for (auto p : cnt) ar[++idx] = p.second;
  sort(ar + 1, ar + idx + 1);
  long long ansmx = -1e9, need = 0;
  dp[idx] = ar[idx];
  for (long long i = idx - 1; i >= 1; i--) {
    ansmx = max(ansmx, ar[i]);
    need = ar[i + 1] / 2;
    if (ar[i] >= need) {
      long long seg = idx - i + 1;
      long long cur = (pw[seg] - 1) * need;
      dp[i] = max(dp[i], cur);
      ar[i] = need;
    } else {
      long long seg = idx - i + 1;
      need = (pw[seg] - 1) * ar[i];
      dp[i] = max(dp[i], need);
    }
  }
  for (long long i = 1; i <= n; i++) {
    ansmx = max(ansmx, dp[i]);
  }
  cout << ansmx << endl;
}
