#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  std::vector<long long int> v(n);
  std::map<long long int, long long int> m;
  for (long long int i = 0; i < n; ++i) {
    cin >> v[i];
    m[v[i]]++;
  }
  multiset<long long int> s;
  std::map<long long int, bool> used;
  for (long long int i = 0; i < n; ++i) {
    if (!used[v[i]]) {
      s.insert(m[v[i]]);
      used[v[i]] = true;
    }
  }
  long long int ans = 0;
  std::vector<long long int> removedElements;
  for (long long int i = 1; i <= 200000; ++i) {
    for (long long int j = 0; j < removedElements.size(); ++j) {
      s.insert(removedElements[j]);
    }
    removedElements.clear();
    long long int curans = 0;
    auto it = s.lower_bound(i);
    if (it == s.end()) {
      break;
    }
    long long int x = *it;
    curans += i;
    x = i;
    removedElements.push_back(*it);
    s.erase(it);
    while (1) {
      x *= 2;
      auto it2 = s.lower_bound(x);
      if (it2 == s.end()) {
        break;
      }
      curans += x;
      removedElements.push_back(*it2);
      s.erase(it2);
    }
    ans = max(ans, curans);
  }
  cout << ans << '\n';
  return 0;
}
