#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

bool used[6000];

int loc[6000];
int va[3000];
int vb[3000];

vector<int> z[6000];
typedef bitset<6000> bt;
bt bz[6000];
int n; string s;

bool chked[6000];
bt ans[6001];
bool valid[6000];

string trans(bt &b) {
	string ret;
	rep(i, 2 * n) {
		if (b[i]) {
			ret.push_back(s[i]);
		}
	}
	return ret;
}
int fre(int i) {
	int id = loc[i];
	if (s[i] == 'a')return vb[id];
	else return va[id];
}

void dfs(int le) {
	if (le == 2 * n)return;
	if (chked[le])return;
	chked[le] = true;
	int len = 0;
	Rep(i, le, 2 * n) {
		len = max(len, (int)z[i].size());
	}
	if (len == 0) {
		string ma = "";
		Rep(i, le, 2 * n) {
			if (fre(i)>i) {
				int to = fre(i) + 1;
				while (to < 2 * n && fre(to)<to)to++;
				dfs(to);
				bt nex = ans[to];
				nex[i] = 1; nex[fre(i)] = 1;
				string snex = trans(nex);
				if (ma < snex) {
					ma = snex;
					ans[le] = nex;
				}
				break;
			}
		}
		return;


	}
	else {
		string ma = "";
		Rep(i, le, 2 * n) {
			if (z[i].size()) {
				int to = z[i].back() + 1;
				while (to < 2 * n && fre(to) < to)to++;
				dfs(to);
				bt nex = bz[i] | ans[to];
				string snex = trans(nex);
				if (ma < snex) {
					ma = snex;
					ans[le] = nex;
				}
			}
		}
	}
	//cout << le << " " << trans(ans[le]) << endl;
}

string nex[6000];
int nexri[6000];
void solve(){
	cin >> n >> s;
	int c[2] = {};
	rep(i, 2 * n) {
		if (s[i] == 'a') {
			va[c[0]] = i;
			loc[i] = c[0];
			c[0]++;
		}
		else {
			vb[c[1]] = i;
			loc[i] = c[1];
			c[1]++;
		}
	}
	fill(valid, valid + 2 * n, true);
	rep(i, 2 * n) {
		int id = loc[i];
		if (s[i] == 'a') {
			if (vb[id] < i)valid[i] = false;
		}
		else {
			if (va[id] < i)valid[i] = false;
		}
	}
	rep(i, 2 * n) {
		if (s[i] == 'b') {
			int id = loc[i];
			if (va[id] > i) {
				bz[i][i] = bz[i][fre(i)] = 1;
				int ri = va[id];
				Rep(j, i + 1, ri) {
					if (s[j] == 'b') {
						bz[i][j] = bz[i][fre(j)] = 1;
						ri = fre(j);
					}
				}
				nex[i] = trans(bz[i]);
				nexri[i] = ri + 1;
			}
		}
	}

	int cur = 0;
	string ans;
	while (cur < 2 * n) {
		string ma = ""; int to = -1;
		Rep(i, cur, 2 * n) {
			if (ma<nex[i]) {
				ma = nex[i]; to = nexri[i];
			}
		}
		if (to < 0) {
			ans += "ab";
			to = fre(cur) + 1;
		}
		else {
			ans += ma;
		}
		while (to<2 * n&&fre(to) < to)to++;
		cur = to;
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 21248