#include <bits/stdc++.h>

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 5e3 + 10;
const int M = (int) 2018 * 2018;
const int K = (int) 15;
const int INF = (int) 1e9 + 7;
const int mod = (int) 998244353;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;

int n;
string s;
string dp[N];

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> n >> s;
	n += n;
	string str = "";
	vector<string> v;
	for (int i = 0, b = 0; i < n; i++) {
		if (s[i] == 'a') b++;
		else b--;
		str += s[i];
		if (!b) {
			//cout << str << " ~~~~~~~\n";
			vec id[2];
			for (int j = 0; j < sz(str); j++) {
				if (str[j] == 'a') { 
					id[0].pb(j);
				} else { 
					id[1].pb(j);
				}
			}
			string cur = "";
			if (id[0][0] < id[1][0]) {
				int cur_id = -1;
				for (int j = 0; j < sz(id[0]); j++) {
					if (id[0][j] > cur_id) {
						cur += "ab";
						cur_id = id[1][j];
					}
				}
			} else {
				set<int> st;
				for (int j = sz(id[0]) - 1; j >= 0; j--) {
					st.insert(id[0][j]);
					st.insert(id[1][j]);
					string tmp = "";
					for (auto it : st) tmp += str[it];
					cur = max(cur, tmp);
				}
			}
			v.pb(cur);
			str = "";
		}
	}
	for (auto it : v) {
		//cout << it << "\n";
	}
	for (int i = sz(v) - 1; i >= 0; i--) {
		dp[i] = max(dp[i + 1], v[i] + dp[i + 1]);
	}
	cout << dp[0];
	return 0;	
}