#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
struct node
{
	int a[6010],l;
	string s;
	node()
	{
		l=0;
		memset(a,0,sizeof(a));
		s="";
	}
	void add(int i,int j)
	{
		int x=lower_bound(a,a+l,j)-a;
		string str="b"+s.substr(0,x)+"a"+s.substr(x,l-x);
		if (str<s)
		{
			return;
		}
		l++;
		for (int k=l;k>x;k--)
		{
			a[k]=a[k-1];
		}
		a[x]=j;
		l++;
		for (int k=l;k;k--)
		{
			a[k]=a[k-1];
		}
		a[0]=i;
		s=str;
	}
};
int n,a[6010],b[6010],c[6010];
char s[6010];
string work(int f,int l,int r)
{
	if (l>r)
	{
		return "";
	}
	//cout<<f<<" "<<l<<" "<<r<<endl;
	//system("pause");
	int s0=0,s1=0;
	for (int i=l;i<=r;i++)
	{
		if ((s[i]-'a')==f)
		{
			s0++;
			a[s0]=i;
		}
		else
		{
			s1++;
			b[a[s1]]=i;
		}
	}
	string res="";
	if (!f)
	{
		int i=l;
		while (i<=r)
		{
			if ((s[i]-'a')!=f)
			{
				i++;
				continue;
			}
			/*
			cout<<i<<endl;
			system("pause");
			*/
			res=res+"ab";
			i=b[i]+1;
		}
	}
	else
	{
		/*
		s0=s1=0;
		int lst=r;
		for (int j=r;j>=l;j--)
		{
			if ((s[j]-'a')==f)
			{
				s0++;
			}
			else
			{
				s1++;
			}
			if (s0==s1)
			{
				node now;
				for (int i=lst;i>=j;i--)
				{
					if ((s[i]-'a')!=f)
					{
						continue;
					}
					now.add(i,b[i]);
				}
				if ((now.s+res)>res)
				{
					res=now.s+res;
				}
				lst=j-1;
			}
		}
		node now;
				for (int i=r;i>=l;i--)
				{
					if ((s[i]-'a')!=f)
					{
						continue;
					}
					now.add(i,b[i]);
				}
				res=now.s;
		*/
		for (int i=l-1;i<=r;i++)
		{
			c[i]=0;
		}
		for (int i=l;i<=r;i++)
		{
			if ((s[i]-'a')==f)
			{
				c[i]=c[i-1]+1;
			}
			else
			{
				c[i]=c[i-1];
			}
		}
		vector<int> v;
		v.clear();
		int mx=l;
		v.push_back(l);
		for (int i=l+1;i<=r;i++)
		{
			//cout<<i<<" "<<c[b[i]]-c[i]<<endl;
			if (c[b[i]]-c[i]>c[b[mx]]-c[mx])
			{
				v.clear();
				mx=i;
				v.push_back(i);
			}
			else if (c[b[i]]-c[i]==c[b[mx]]-c[mx])
			{
				v.push_back(i);
			}
		}
		for (int j=0;j<v.size();j++)
		{
			string now="";
			for (int i=v[j];i<=r;i++)
			{
				if ((s[i]-'a')==f)
				{
					now.push_back(s[i]);
				}
				else
				{
					if (i>=b[v[j]])
					{
						now.push_back(s[i]);
					}
				}
			}
			//cout<<now<<endl;
			res=max(res,now);
		}
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",&s);
	int sa=0,sb=0,lst=2*n-1;
	string ans="";
	for (int i=2*n-1;i>=0;i--)
	{
		if (s[i]=='a')
		{
			sa++;
		}
		else
		{
			sb++;
		}
		if (sa!=sb)
		{
			continue;
		}
		if (s[i]=='a')
		{
			if (s[i-1]=='b')
			{
				continue;
			}
			if (lst==2*n-1)
			{
				ans=work(0,i,lst)+ans;
			}
			lst=i-1;
		}
		else
		{
			string str=work(1,i,lst);
			/*
			for (int j=i;j<=lst;j++)
			{
				str.push_back(s[j]);
			}
			*/
			if ((str+ans)>ans)
			{
				ans=str+ans;
			}
			//cout<<ans<<endl;
			lst=i-1;
		}
	}
	/*
	for (int i=0;i<2*n;i++)
	{
		if (s[i]=='a')
		{
			sa++;
		}
		else
		{
			sb++;
		}
		if (sa==sb)
		{
			if (i==2*n-1 || s[i+1]!=s[lst])
			{
				if (i==2*n-1 || (s[i+1]!=s[lst] && s[lst]!='a'))
				{
					ans=ans+work(s[lst]-'a',lst,i);
				}
				sa=sb=0;
				lst=i+1;
			}
		}
	}
	*/
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384