#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long double PI = 4 * atan(1);
long long n, a[200001], Max, prv, cnt, ans;
vector<int> v;
void check(long long i) {
  long long cur = 0;
  for (int j = v.size() - 1; j >= 0; j--) {
    if (v[j] >= i)
      cur += i;
    else
      break;
    if (i == 0 || (int)(i & 1)) break;
    i /= 2;
  }
  ans = max(ans, cur);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  prv = a[0];
  cnt = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] != prv) {
      v.push_back(cnt);
      cnt = 1;
    } else {
      cnt++;
    }
    prv = a[i];
  }
  v.push_back(cnt);
  sort(v.begin(), v.end());
  Max = v[v.size() - 1];
  for (int i = Max + 1 - 1; i >= Max / 2; i--) {
    check(i);
  }
  cout << ans;
  return 0;
}
