#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << '(' << p.first << ',' << p.second << ')';
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  for (int i = 0; i < (int)v.size(); i++) {
    if (i) {
      os << ',';
    }
    os << v[i];
  }
  os << '}';
  return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &...args) {
  cerr << " " << x;
  debugg(args...);
}
struct Setup {
  Setup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} __Setup;
using ll = long long;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  int n;
  cin >> n;
  map<int, int> cnt;
  for (int i = 0; i < int(n); i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  vector<int> v;
  for (auto p : cnt) v.push_back(p.second);
  sort((v).begin(), (v).end());
  int ans = 0;
  for (int s = 1; s < int(v.back() + 1); s++) {
    int now = s;
    int res = now;
    int i = int(v.size()) - 1;
    while (now % 2 == 0 && i > 0) {
      now /= 2;
      i--;
      if (v[i] < now) break;
      res += now;
    }
    chmax(ans, res);
  }
  cout << ans << endl;
}
