#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5 + 10;
int dp[Maxn << 1];
vector<int> ve;
map<int, int> ma;
int n;
int main() {
  int n;
  int x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    ma[x]++;
  }
  for (auto i : ma) ve.push_back(i.second);
  sort(ve.begin(), ve.end());
  int ve_size = ve.size();
  int ans = 0;
  for (int i = ve_size - 1; i >= 0; i--) {
    for (int j = 1; j <= ve[i]; j++) {
      dp[j] = max(dp[j], j + dp[j << 1]);
      ans = max(ans, dp[j]);
    }
  }
  cout << ans << endl;
  return 0;
}
