#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

string s;
vector<string> ss;
char a = 'a';
char b = 'b';

vector<int> make_jump(string s){
	int n = s.size()/2;
	vi jump(s.size(), -1);
	int ia = -1, ib=-1;
	rep(k,n){
		ia++;
		ib++;
		while(s[ia]==b)ia++;
		while(s[ib]==a)ib++;
		jump[ia] = ib;
		jump[ib] = ia;
	}
	return jump;

}

vector<string> find_kouho(string s){
	vector<string> ret;
	vi jump = make_jump(s);
	if(s[0]==a){
		int n = s.size()/2;
		int i=0;
		int cnt = 0;
		while(i<s.size()){
			assert(s[i]==a);
			cnt++;
			i = jump[i]+1;
			while(i<s.size() && s[i]==b )i++;
		}
		string ret_s;
		rep(j,cnt){
			ret_s.push_back(a);
			ret_s.push_back(b);
		}
		ret.push_back(ret_s);
	}
	if(s[0]==b){
		rep(start,s.size()) if(s[start]==b){
			string ret_s;
			FOR(i,start, s.size()){
				if(s[i]==b || (s[i]==a && i>=jump[start])  )ret_s.push_back(s[i]);
			}
			ret.push_back(ret_s);
		}
	}
	return ret;
}

void _main(istream &inp){

	int si;
	inp >> si >> s;
	assert(s.size()==2*si);
	int start = 0;
	int cnt = 0;
	for(int i=0; i<=s.size(); i++){
		if(i>0 && cnt==0){
			ss.push_back(string(s.begin()+start, s.begin()+i));
			start = i;
		}
		if(i<s.size()){
			if(s[i]==b)cnt++;
			else cnt--;
		}
	}
	//debug(ss);
	string cur;
	for(int k=ss.size()-1; k>=0; k--){
		string best = cur;
		for(string u:find_kouho(ss[k]) ){
			if(u+cur >= best){
				best = u+cur;
			}
		}
		cur = best;
	}
	cout << cur << endl;
}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 16256