#include <bits/stdc++.h>
using namespace std;

const int MAXN = 6e3 + 5;

int N;
string s;
string dp[MAXN];
bool good[MAXN];
vector <int> a, b;
int idx[MAXN];
bool taken[MAXN];

void load() {
	cin >> N >> s;
}

string get(int x) {
	string res = "";
	while (x <= N) {
		if (s[x] == 'a' && b[idx[x]] > x) {
			res += "ab";
			x = b[idx[x]];
		}
		x++;
	}
	return res;
}

string greedy(int pos) {
	memset(taken, false, sizeof taken);
	
	vector <int> v;
	for (; pos <= N; pos++) {
		if (!v.empty() && pos > v.back())
			break;
		if (good[pos]) {
			v.push_back(a[idx[pos]]);
			taken[pos] = taken[v.back()] = true;
		}
	}
	
	string res = "";
	for (int i = 1; i <= N; i++)
		if (taken[i])
			res += s[i];
	
	if (!dp[pos].empty())
		return res + dp[pos];
	
	return res + get(pos);
}

string solve() {
	N *= 2;
	s = ' ' + s;
	for (int i = 1; i <= N; i++)
		if (s[i] == 'a')
			a.push_back(i);
		else
			b.push_back(i);
	
	for (int i = 0; i < b.size(); i++) {
		if (a[i] > b[i]) 
			good[b[i]] = true;
		idx[a[i]] = i;
		idx[b[i]] = i;
	}
	
	for (int i = N; i >= 0; i--) {
		dp[i] = dp[i + 1];
		if (good[i]) {
			string tmp = greedy(i);
			if (tmp > dp[i])
				dp[i] = tmp;
		}
	}
	
	return dp[0].empty() ? get(1) : dp[0];
}

int main() {
	load();
	cout << solve() << endl;
	return 0;
}