#include <bits/stdc++.h>
const int _MOD = 1000000007;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<int> c;
  c.push_back(1);
  int sz = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1]) {
      c[sz - 1]++;
    } else {
      c.push_back(1);
      sz++;
    }
  }
  if (sz == 1) {
    cout << c[0];
    return 0;
  }
  sort(c.begin(), c.end(), greater<int>());
  int maxcnt = 0;
  int k = c[0];
  for (int i = 1; i <= k; i++) {
    int cnt = i;
    c[0] = i;
    int lst = i;
    for (int j = 1; j < sz; j++) {
      if (lst % 2 == 0 && lst / 2 <= c[j]) {
        lst /= 2;
        cnt += lst;
      } else {
        break;
      }
    }
    if (cnt > maxcnt) {
      maxcnt = cnt;
    }
  }
  cout << maxcnt;
  return 0;
}
