#include <bits/stdc++.h>
using namespace std;
long long fast_power(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power % 2 == 1) result = (result * base);
    base = (base * base);
    power = power / 2;
  }
  return result;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long i, j, a[n + 1];
  for (i = 0; i < n; ++i) cin >> a[i];
  map<long long, long long> m;
  for (i = 0; i < n; ++i) {
    if (m.find(a[i]) == m.end())
      m[a[i]] = 1;
    else
      m[a[i]]++;
  }
  vector<long long> v;
  for (auto it : m) {
    v.push_back(it.second);
  }
  sort(v.begin(), v.end());
  long long c = 0, z = v.size();
  long long ma = v[z - 1];
  for (i = z - 1; i > 0; --i) {
    if (v[i - 1] >= v[i] / 2) v[i - 1] = v[i] / 2;
    ma = max(ma, v[i - 1] * (fast_power(2, z - i + 1) - 1));
    if (v[i] == 0) break;
  }
  cout << ma << "\n";
  return 0;
}
