#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int main()
{
	map<int, int> idx;
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i), idx[a[i]]++;
	vector<int> v;
	for (auto i : idx)v.push_back(i.second);
	long long add = 1, ans = 0, tmp, ty = 1;
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++)
		for (; ty <= v[i]; ty++) {
			add = ty;
			tmp = add;
			add *= 2;
			for (int k = i + 1; k < v.size(); k++)
				if (v[k] >= add)
					tmp += add, add *= 2;
			ans = max(ans, tmp);
		}
	printf("%lld", ans);
	return 0;
}