#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5;
int n, a[MAX_N + 1];
map<int, int> hs;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], hs[a[i]]++;
  set<pair<int, int> > s;
  for (auto p : hs) s.insert({p.second, p.first});
  int ans = 0;
  for (auto p : hs) {
    s.erase({p.second, p.first});
    for (int i = 1; i <= p.second; ++i) {
      int sum = i;
      int x = 2 * i;
      vector<pair<int, int> > removed;
      while (x <= n) {
        set<pair<int, int> >::iterator it = s.lower_bound({x, 0});
        if (it != s.end()) {
          sum += x;
          removed.push_back(*it);
          s.erase(it);
          x *= 2;
        } else
          break;
      }
      for (auto pr : removed) s.insert(pr);
      ans = max(ans, sum);
    }
    s.insert({p.second, p.first});
  }
  cout << ans;
  return 0;
}
