#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 3003;
int n;
string S[N], MX[N];
int main()
{
    cin >> n >> S[0];
    for (int i = 1; i < n; i++)
    {
        int a = 0, b = 0;
        for (int j = 0; j < (int)S[i - 1].size(); j++)
        {
            if (S[i - 1][j] == 'a') a ++;
            if (S[i - 1][j] == 'b') b ++;
            if (S[i - 1][j] == 'a' && a > 1) S[i] += 'a';
            if (S[i - 1][j] == 'b' && b > 1) S[i] += 'b';
        }
    }
    for (int i = n - 1; ~ i; i --)
    {
        int mb = -1;
        for (int j = 0; j < n + n - i - i && !~mb; j++)
            if (S[i][j] == 'b') mb = j;
        MX[i] = MX[i + 1];
        if (S[i][0] == 'a')
            MX[i] = max(MX[i], "ab" + MX[i + mb]);
        else
        {
            string str = "";
            int a = 0, b = 0;
            for (int j = 0; j < n + n - i - i; j++)
            {
                str += S[i][j];
                if (S[i][j] == 'a') a ++;
                if (S[i][j] == 'b') b ++;
                if (a == b)
                    MX[i] = max(MX[i], str + MX[i + 1 + (j >> 1)]);
            }
        }
    }
    return cout << MX[0], 0;
}