#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long sign = 1;
  long long x = 0;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') sign = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * sign;
}
inline void wonl() { putchar('\n'); }
inline void wws() { putchar(' '); }
inline void dbg() { cout << endl; }
inline void ww(long long k) {
  if (k < 0) putchar('-'), k *= -1;
  char ch[20];
  int num = 0;
  while (k) ch[++num] = k % 10, k /= 10;
  if (num == 0) ch[++num] = 0;
  while (num) putchar(ch[num--] + '0');
}
const int N = 1e5 + 4;
template <typename T, typename... V>
inline void wonl(T t, V... v) {
  ww(t);
  if (sizeof...(v)) putchar(' ');
  wonl(v...);
}
template <typename T, typename... V>
inline void wws(T t, V... v) {
  ww(t);
  if (sizeof...(v)) putchar(' ');
  wws(v...);
}
template <typename T, typename... V>
inline void dbg(T t, V... v) {
  cout << ' ' << t;
  dbg(v...);
}
void solve() {
  int n = read(), a;
  map<int, int> ma;
  for (int i = 0; i < n; i++) a = read(), ma[a]++;
  vector<int> v;
  for (auto it : ma) v.push_back(it.second);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  long long num = 1;
  while (v[0] >= num) num *= 2;
  long long fans = 0;
  while (num) {
    long long ter = num;
    long long a = INT_MAX;
    int k = 0;
    while (ter != 0 && k < v.size()) {
      a = min(a, v[k] / ter), ter = ter / 2, k++;
    }
    if (ter == 0) fans = max(fans, a * (num * 2 - 1));
    num = num / 2;
  }
  wonl(fans);
}
int main() {
  solve();
  return 0;
}
