#include <bits/stdc++.h>
using namespace std;
bool isprime(long long a) {
  for (long long i = 2; i <= pow(a, 0.5); ++i) {
    if (a % i == 0) {
      return false;
    }
  }
  return true;
}
long long ceil(long long a, long long b) {
  long long c = (a + b - 1) / b;
  return c;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  }
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long power_mod(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  long long temp = power_mod(a, b / 2);
  temp = (temp * temp) % 1000000007;
  if (b % 2) {
    temp = (temp * a) % 1000000007;
  }
  return temp;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    long long n;
    cin >> n;
    map<long long, long long> mapi;
    vector<long long> v(n);
    for (long long i = 0ll; i < n; ++i) {
      cin >> v[i];
      mapi[v[i]]++;
    }
    multiset<long long> freq;
    long long maxi = 0;
    for (auto it : mapi) {
      freq.insert(it.second);
      maxi = max(maxi, it.second);
    }
    for (auto it : freq) {
    }
    long long ans = 1;
    for (long long start = 1; start <= maxi; ++start) {
      vector<long long> removed;
      long long temp = 0;
      long long curr = start;
      while (1) {
        auto it = freq.lower_bound(curr);
        if (it == freq.end()) {
          break;
        }
        temp += curr;
        curr *= 2;
        removed.push_back(*it);
        freq.erase(it);
      }
      ans = max(ans, temp);
      for (long long p : removed) {
        freq.insert(p);
      }
    }
    cout << ans << "\n";
  }
}
