#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool mmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool mmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  map<long long, long long> cnt;
  for (long long i = 0; i < n; i++) {
    long long first;
    cin >> first;
    cnt[first]++;
  }
  vector<long long> v;
  for (auto i : cnt) {
    v.push_back(i.second);
  }
  sort((v).begin(), (v).end());
  long long ans = 0;
  for (long long i = 1; i <= v.back(); i++) {
    long long cur = i;
    long long pos = (long long)v.size() - 1;
    long long res = cur;
    while (cur % 2 == 0 and pos > 0) {
      pos--;
      cur /= 2;
      if (v[pos] < cur) break;
      res += cur;
    }
    ans = max(ans, res);
  }
  cout << ans;
  return 0;
}
