#include <bits/stdc++.h>
using namespace std;
const int maxn = 6000;
int n;
char s[maxn + 10];
int a[maxn + 10], b[maxn + 10], bel[maxn + 10];
bool mk[maxn + 10];
string v[maxn + 10], f[maxn + 10];
int m;

void build(char c, int *x) {
	for (int i = 1, p = 1; i <= n; ++i) {
		while (s[p] != c) ++p;
		x[i] = p; bel[p] = i;
		++p;
	}
}

void addin(int l, int r) {
	string str = "";
	int mn = 1e9, mx = 0;
	for (int i = l; i <= r; ++i) {
		mn = min(mn, bel[i]);
		mx = max(mx, bel[i]);
	}
	if (a[mn] < b[mn]) {
		int pos = 0;
		for (int i = mn; i <= mx; ++i)
			if (a[i] > pos) {
				str += "ab"; pos = b[i];
			}
	} else {
		memset(mk, 0, sizeof mk);
		str = "A";
		for (int i = mx; i >= mn; --i) {
			mk[a[i]] = mk[b[i]] = 1;
			string tmp;
			for (int j = 1; j <= n * 2; ++j)
				if (mk[j]) tmp += s[j];
			str = max(str, tmp);
		}
	}
	v[++m] = str;
}

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	build('a', a); build('b', b);
	for (int i = 1, lst; i <= n * 2; i = lst) {
		int r = max(a[bel[i]], b[bel[i]]);
		for (lst = i; lst <= r; ++lst)
			r = max(r, max(a[bel[lst]], b[bel[lst]]));
		addin(i, lst - 1);
	}
	for (int i = m; i >= 1; --i)
		f[i] = max(f[i + 1], v[i] + f[i + 1]);
	cout << f[1];
}
