#include <bits/stdc++.h>
using namespace std;
ifstream fi("test.txt");
ifstream fir("inp.txt");
ofstream fo("out.txt");
const long long MOD = 1e9 + 7;
const long long base = 269;
const int ooi = 1 << 30;
const int N = 1e5 + 5;
long long n, m, q, k, pos, rs, t, T, cnt, rs1;
long long maxx = -1e9, minn = 1e9;
map<int, int> a;
map<int, int>::iterator it;
vector<int> mark;
long long dp[4 * N];
int main() {
  cin >> n;
  for (long long(i) = 0; (i) < (n); (i)++) {
    int inp;
    cin >> inp;
    a[inp]++;
  }
  for (it = a.begin(); it != a.end(); it++) {
    mark.push_back(it->second);
  }
  sort(mark.begin(), mark.end());
  long long ans = 0;
  for (long long(i) = (mark.size() - 1); (i) >= (0); (i)--) {
    for (long long(j) = 1; (j) <= (mark[i]); (j)++) {
      dp[j] = max(dp[j], j + dp[j * 2]);
      ans = max(ans, dp[j]);
    }
  }
  cout << ans;
}
