#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=6e3+5;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
//inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,tmp,p[MAXN],kind[MAXN],cnt,bel[MAXN];string s,F[MAXN];
int main(){
	n=read(),cin>>s,p[0]=-1;
	Rep(i,0,2*n-1){
		tmp+=s[i]=='a'?1:-1;
		if(!tmp)p[++cnt]=i,kind[cnt]=s[i]=='a';
	}bool flg=1;
	Red(i,cnt,1){
		if(kind[i]){
			int s1=0,s2=0;
			Rep(j,p[i-1]+1,p[i])if(s[j]=='a')bel[j]=++s1;else bel[j]=++s2;
			F[i]=F[i+1],flg=0;
			Rep(j,1,s1){
				string cur;
				Rep(k,p[i-1]+1,p[i])if(bel[k]>=j)cur+=s[k];
				F[i]=max(F[i],cur+F[i+1]);
			}
		}else if(flg){
			int s1=0,s2=0;
			Rep(j,p[i-1]+1,p[i])if(s[j]=='a')bel[j]=++s1;else bel[j]=++s2;
			for(int r=p[i-1]+1;;){
				for(;r<=p[i]&&s[r]=='b';r++);
				if(r>p[i])break;int t=bel[r];
				for(r++,F[i]+="ab";bel[r]!=t;r++);r++;
			}F[i]+=F[i+1];
		}else F[i]=F[i+1];
	}cout<<F[1]<<'\n';
	return 0;
}


