//                             In The Name Of Allah                                           
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 1e5 + 100, OO = 1e9 + 7, K = 3e5 + 100, T = 5, M = 1e9 + 7, P = 6151, SQ = 450, lg = 20;
typedef pair <int, int> pii;
int p[N], it[N], pw[N], hs[N], en[N], n;
string s, st, ans[N];
int mark[N];

int get(int r, int l) {
	if(r < l)
		return 0;
	int cnt = (hs[r] - (hs[l - 1] * pw[r - l + 1] % M) + M) % M;
	return cnt;
}

bool cmp(int x, int y) {
	int l = 0, r = min(en[x] - x, en[y] - y) + 1;
//	cout << x << " " << y << " BEGIN" << endl;
	while(l < r) {
		int mid = (l + r) >> 1;
//		cout << mid << " " << x + mid - 1 << " " << y + mid - 1 << " " << get(x + mid - 1, x) << " " << get(y + mid - 1, y) << endl;
		if(get(x + mid - 1, x) == get(y + mid - 1, y))
			l = mid + 1;
		else
			r = mid;
	}
	if(l == min(en[x] - x, en[y] - y) + 1)
		return x < y;
	return s[x + l - 1] < s[y + l - 1];
}

void solve(int x) {
	int mx = 0;
	for(int i = 1; i < x; i++) 
		mx = max(mx, mark[i]);
	if(mark[x] <= mx)
		return;
//	cout << x << " " << mx << " " << mark[x] << endl;
	if(s[x - 1] == 'a') {
		ans[x] = "ab";
		for(int i = x + 1; i <= n; i++) {
			if(mark[i] == mark[x]) {
				ans[x] += ans[i + 1];
				break;
			}
		}
	}
	else {
		int cnt = 1;
		ans[x] = "b";
		for(int i = x + 1; i <= n; i++) {
		//	cout << x << " " << i << " ** " << mark[i] << endl;
			if(mark[i] <= mx)
				continue;
		//	cout << x << " " << i << " " << s[i - 1] << endl;
			ans[x] += s[i - 1];
			if(s[i - 1] == 'a')
				cnt--;
			else
				cnt++;
			if(cnt == 0) {
		//		cout << x << " " << ans[x] << endl;
				ans[x] += ans[i + 1];
				break;
			}
		}
	}
}

int32_t main() {
	use_fast;
	cin >> n >> s;
	n *= 2;
	int a0 = 0, a1 = 0;
	for(int i = 1; i <= n; i++) {
		if(s[i - 1] == 'a')
			a0++, mark[i] = a0;
		else
			a1++, mark[i] = a1;
//		cout << i << " " << mark[i] << endl;
	}
	for(int i = n; i; i--) {
		solve(i), ans[i] = max(ans[i], ans[i + 1]);
//		cout << i << " " << ans[i] << endl;
	}
	cout << ans[1] << endl;
	return 0;
	vector <int> v, t;
	pw[0] = 1;
	for(int i = 1; i <= n; i++) {
		p[i] = p[i - 1] + (s[i - 1] == 'a') - (s[i - 1] == 'b');
		hs[i] = (hs[i - 1] * P + (int)(s[i - 1] - 'a' + 1)) % M;
		pw[i] = (pw[i - 1] * P) % M;
		if(p[i - 1] == 0)
			v.pb(i);
	}
	v.pb(n + 1);
	for(int i = 0; i < (int)v.size() - 1; i++) 
		if(s[v[i] - 1] == 'b')
			t.pb(v[i]), en[v[i]] = v[i + 1];
	sort(t.begin(), t.end(), cmp);
	int pre = 0;
	string ans = "";
	for(auto u : t) {
		if(u <= pre)
			continue;
		for(int i = u; i < en[u]; i++)
			ans += s[i - 1];
		pre = en[u] - 1;
	}
	int n0 = 0, n1 = 0;
	bool is = false;
	for(int i = pre + 1; i <= n; i++) {
		if(s[i - 1] == 'a') {
			n0++;
			if(is)
				mark[n0] = true;
			else
				ans += "ab", is = true;
		}
		else {
			n1++;
			if(mark[n1])
				continue;
			if(is == true)
				is = false;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 25316