#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 6080;

int N, match[MAX_N];
string S, F[MAX_N];

void init() {
    cin >> N;
    cin >> S;
    queue<int> que;
    for (int i = 0; i < 2 * N; i++) {
        if (que.empty() || S[que.front()] == S[i]) que.push(i);
        else {
            int j = que.front(); que.pop();
            match[j] = i; match[i] = j;
        }
    }
}

void solve() {
    static bool sel[MAX_N];
    for (int i = 2 * N - 1; i >= 0; i--) {
        if (match[i] > i) {
            if (S[i] == 'a') F[i] = "ab" + F[match[i] + 1];
            else {
                fill_n(sel, 2 * N, false);
                int lvl = 0, j = i;
                for (j = i; j < 2 * N && (j == i || lvl); j++) {
                    if (S[j] == 'b') {
                        lvl++;
                        sel[match[j]] = true;
                        F[i].push_back('b');
                    } else if(sel[j]) {
                        F[i].push_back('a');
                        lvl--;
                    }
                }
                F[i] += F[j];
            }
        }
        F[i] = max(F[i], F[i + 1]);
    }
    cout << F[0] << endl;
}

int main() {
    init();
    solve();
}
