#include <bits/stdc++.h>
#pragma GCC optimize ("O2,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;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=6010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, sum;
int A[2][MAXN];
bool mark[MAXN];
string ans, S, T;

string Solve(string T){
	string res;
	int a=0, b=0;
	for (int i=T.size()-1; ~i; i--){
		if (T[i]=='a') A[0][a++]=i;
		if (T[i]=='b') A[1][b++]=i;
		mark[i]=0;
	}
	if (T[0]=='a'){
		int last=-1;
		for (int i=a-1; ~i; i--) if (last<A[0][i]){
			res+="ab";
			last=A[1][i];
		}
		return res;
	}
	for (int i=0; 2*i<T.size(); i++){
		mark[A[0][i]]=mark[A[1][i]]=1;
		string s;
		for (int j=0; j<T.size(); j++) if (mark[j]) s+=T[j];
		res=max(res, s);
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>S;
	for (int i=2*n-1; ~i; i--){
		if (S[i]=='a') sum++;
		else sum--;
		T=S[i]+T;
		if (sum==0){
			T=Solve(T);
			ans=max(ans, T+ans);
			T="";
		}
	}
	cout<<ans<<"\n";
	
	return 0;
}
/*
5
aaabababbb

*/