#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int a[maxn], tot;
int dp[maxn];
int main() {
  int n, x;
  map<int, int> mp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &x), mp[x]++;
  for (auto& m : mp) a[tot++] = m.second;
  sort(a, a + tot, greater<int>());
  for (int i = 0; i < tot; i++) {
    for (int j = 1; j <= a[i]; j++) dp[j] = max(dp[j], dp[j << 1] + j);
  }
  printf("%d\n", *max_element(dp + 1, dp + 1 + a[0]));
  return 0;
}
