#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 998244353;
vector<long long> v;
vector<pair<long long, long long>> g;
map<long long, long long> m;
long long search(long long x, long long m, long long sum) {
  if (g[x].first >= m && x < g.size()) {
    if (m % 2) return sum + m;
    return search(x + 1, m / 2, sum + m);
  } else
    return sum;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (!m[x]) v.push_back(x);
    m[x]++;
  }
  for (int i = 0; i < v.size(); i++) {
    g.push_back({m[v[i]], v[i]});
  }
  sort(g.begin(), g.end());
  reverse(g.begin(), g.end());
  long long ans = g[0].first;
  if (g[0].first % 2) g[0].first--;
  while (g[0].first) {
    ans = max(ans, search(1, g[0].first / 2, g[0].first));
    g[0].first -= 2;
  }
  cout << ans << endl;
}
