#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define min(a,b) (a<b?a:b)
#define ll long long
//#define file
using namespace std;

struct type{
	char a[6001];
	int n;
	void add(char ch) {a[++n]=ch;}
} ans,s,Ans;
int a[6001][3],c[6001][2],n,i,j,k,l,sum,tot,s1,s2;
char st[6001];
bool bz;

bool pd(type a,type b)
{
	int i;
	
	fo(i,1,min(a.n,b.n))
	if (a.a[a.n-i+1]!=b.a[b.n-i+1])
	return a.a[a.n-i+1]<b.a[b.n-i+1];
	return a.n<b.n;
}

int main()
{
	#ifdef file
	freopen("agc026e.in","r",stdin);
	#endif
	
	scanf("%d",&n);
	scanf("%s",st+1);
	
	fo(i,1,n+n)
	{
		if (!sum)
		{
			++tot;
			a[tot][0]=i;
			a[tot][2]=st[i]=='b';
		}
		sum+=(st[i]=='a')?1:-1;
		if (!sum) a[tot][1]=i;
	}
	
	fd(l,tot,1)
	if (!a[l][2])
	{
		if (!bz)
		{
			s1=s2=0;
			fo(i,a[l][0],a[l][1])
			{
				if (st[i]=='a')
				++s1,c[s1][0]=i;
				else
				++s2,c[s2][1]=i;
			}
			
			k=(a[l][1]-a[l][0]+1)/2,j=0;
			fo(i,1,k)
			if (j<c[i][0])
			ans.add('b'),ans.add('a'),j=c[i][1];
		}
	}
	else
	{
		bz=1;Ans=ans;
		fd(i,(a[l][1]-a[l][0]+1)/2,0)
		{
			s=ans;
			s1=s2=0;
			fd(j,a[l][1],a[l][0])
			{
				if (st[j]=='a')
				{++s1;if (s1<=i) s.add('a');}
				else
				{++s2;if (s2<=i) s.add('b');}
			}
			if (pd(Ans,s)) Ans=s;
		}
		ans=Ans;
	}
	
	fd(i,ans.n,1) putchar(ans.a[i]);
	putchar('\n');
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}