#include <bits/stdc++.h>
using namespace std;
long long int max2 = 1000000007;
long long int power(long long int base, long long int exp) {
  long long int ans = 1;
  while (exp) {
    if (exp % 2 == 1) {
      ans *= base;
      ans %= max2;
    }
    exp /= 2;
    base *= base;
    base %= max2;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
  int tab;
  auto geti = [&]() {
    cin >> tab;
    return tab;
  };
  ;
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  vector<long long int> v;
  long long int index = 0;
  long long int count = 1;
  for (long long int i = 1; i < n; i++) {
    if (arr[i] != arr[index]) {
      v.push_back(count);
      count = 1;
      index = i;
    } else {
      count++;
    }
  }
  v.push_back(count);
  sort(v.begin(), v.end());
  long long int s = v.size();
  if (s == 1) {
    cout << v[0] << endl;
    return 0;
  }
  if (v[s - 1] == 1) {
    cout << 1 << endl;
    return 0;
  }
  count = v[s - 1];
  long long int maxy = v[s - 1];
  if (maxy % 2 != 0) {
    maxy--;
  }
  for (long long int i = maxy; i >= 2; i -= 2) {
    long long int c = i;
    long long int check = i / 2;
    for (long long int j = s - 2; j >= 0; j--) {
      if (v[j] >= check) {
        c += check;
        if (check % 2 == 0) {
          check = check / 2;
        } else {
          goto here;
        }
      } else {
        goto here;
      }
    }
  here:
    if (count <= c) {
      count = c;
    }
  }
  cout << count << endl;
  return 0;
}
