#include <stdio.h>

#include <algorithm>

#include <string>

using namespace std;


int N; char S[6060];
int A[3030], B[3030], C[6060];


int main()
{

	scanf("%d %s", &N, S);

	A[0] = B[0] = -1;

	for (int i=0, a=0, b=0;i<N*2;i++){
		if (S[i] == 'a') A[++a] = i;
		if (S[i] == 'b') B[++b] = i;
	}

	string ans = "", best = "";
	int l = N*2+1, lm = N*2+1; bool see = false;
	for (int i=N;i>=0;i--){
		if (A[i] >= B[i]){
			if (A[i] < l) best = ans, lm = l;

			if (i){
				C[A[i]] = C[B[i]] = 1;
				string now = "";
				for (int j=B[i];j<lm;j++) if (C[j]) now += S[j];

				string mk = now + best;
				if (ans < mk)
					ans = move(mk);
			}

			l = B[i];
			see = true;
		}
		else if (!see){
			if (B[i] < l){
				ans += "ab";
				best += "ab";
				l = A[i];
			}
		}
	}

	puts(ans.c_str());
	return 0;
}
