#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  long x;
  map<long, int> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    m[x]++;
  }
  vector<int> a;
  for (auto x : m) {
    a.push_back(x.second);
  }
  sort(a.begin(), a.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < a[0] + 1; i++) {
    x = i;
    int j = 0, cnt = 0;
    while (a[j] >= x and j < a.size() and x > 0) {
      cnt += x;
      j++;
      if ((x & 1) != 0) break;
      x /= 2;
    }
    ans = max(ans, cnt);
  }
  cout << ans;
}
