#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
int spow(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret *= a;
    a *= a;
    b >>= 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  long long number[MAX];
  cin >> n;
  for (int a = 0; a < n; a++) cin >> number[a];
  sort(number, number + n);
  int vis[MAX] = {0};
  int cou = 1, d = 0;
  int po[MAX] = {0};
  for (int a = 1; a < n; a++) {
    if (number[a] != number[a - 1]) {
      po[d++] = cou;
      vis[cou] = 1;
      cou = 1;
    } else
      cou++;
  }
  po[d++] = cou;
  if (d == 1) {
    cout << po[d - 1] << endl;
    return 0;
  }
  sort(po, po + d);
  int maxx = 0;
  for (int a = 1; a <= po[d - 1]; a++) {
    if (a % 2 != 0) {
      maxx = max(a, maxx);
      continue;
    }
    int cou = 1;
    int t = a / 2;
    for (int b = d - 2; b >= 0; b--) {
      if (t == 0) break;
      if (po[b] < t)
        break;
      else {
        cou++;
        if (t % 2 == 0)
          t = t / 2;
        else
          break;
      }
    }
    maxx = max(2 * a - 2 * a / spow(2, cou), maxx);
  }
  cout << maxx << endl;
  return 0;
}
