#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto& x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    mp[ar[i]]++;
  }
  vector<int> v;
  for (auto it : mp) v.push_back(it.second);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  cerr << "["
       << "v"
       << "]:",
      debug_out(v);
  vector<vector<int>> num(20);
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j <= i; j++) num[i].push_back(pow(2, j));
    reverse(num[i].begin(), num[i].end());
  }
  int mx = 0, curr = 0, mn;
  for (int i = 0; i < 20; i++) {
    curr = 0, mn = INT_MAX;
    if (i == v.size()) break;
    for (int j = 0; j < i + 1; j++) {
      mn = min(mn, v[j] / num[i][j]);
    }
    cerr << "["
         << "mn"
         << "]:",
        debug_out(mn);
    curr = mn * (pow(2, i + 1) - 1);
    cerr << "["
         << "curr"
         << "]:",
        debug_out(curr);
    mx = max(mx, curr);
  }
  cout << mx << endl;
}
