#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << " " << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long N = 100005;
const long long mod = 1e9 + 7;
long long mx = -1e18, mn = 1e18;
void inp_out() {}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  inp_out();
  {
    long long i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
    cin >> n;
    long long a[n];
    map<long long, long long> mp;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }
    vector<long long> v;
    for (auto ele : mp) {
      v.push_back(ele.second);
    }
    sort(v.begin(), v.end());
    m = v.size();
    i = m - 1;
    while (i >= 0) {
      for (j = v[i]; j >= 0; j--) {
        long long cur = j;
        long long cur_ind = i;
        sum = 0;
        sum += cur;
        if (cur % 2 == 0) {
          cur /= 2;
          while (1) {
            if (cur == 0) {
              break;
            }
            if (cur_ind == 0) {
              break;
            }
            if (v[cur_ind - 1] < cur) {
              break;
            }
            cur_ind = cur_ind - 1;
            sum += cur;
            if (cur % 2 != 0) break;
            cur /= 2;
          }
        }
        ans = max(ans, sum);
      }
      i--;
    }
    cout << ans << "\n";
  }
  return 0;
}
