#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int n, len;
vector<int> v;
int check(int x) {
  int cnt = 0;
  for (int i = (len - 1); i >= 0 && x > 0; i--) {
    if (x > v[i])
      break;
    else {
      cnt += x;
      if (x % 2 != 0)
        break;
      else
        x /= 2;
    }
  }
  return cnt;
}
int main() {
  cin >> n;
  int inp[n];
  for (int i = 0; i < n; i++) cin >> inp[i];
  sort(inp, inp + n);
  int prev = inp[n - 1];
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (inp[i] == prev) {
      cnt++;
    } else {
      v.push_back(cnt);
      cnt = 1;
      prev = inp[i];
    }
  }
  v.push_back(cnt);
  sort(v.begin(), v.end());
  len = v.size();
  int x = v[len - 1];
  int m = -1;
  for (int i = x; i >= 1; i--) {
    m = max(m, check(i));
  }
  cout << m;
  return 0;
}
