#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        string s;
        cin >> s;
        int acc = 0;
        vector<string> hoge;
        string cur = "";
        for (int i = 0; i < 2 * n; i ++) {
                if (s[i] == 'a') {
                        acc ++;
                } else {
                        acc --;
                }
                cur += s[i];
                if (acc == 0) {
                        hoge.push_back(cur);
                        cur = "";
                }
        }
        vector<string> best;
        for (int f = 0; f < (int) hoge.size(); f ++) {
                string t = hoge[f];
                int N = (int) t.size();
                int ac = 0, bc = 0;
                vector<int> p(N);
                for (int i = 0; i < N; i ++) {
                        if (t[i] == 'a') {
                                p[i] = ac ++;
                        } else {
                                p[i] = bc ++;
                        }
                }
                vector<int> pos(N);
                for (int i = 0; i < N; i ++) {
                        for (int j = i + 1; j < N; j ++) {
                                if (p[i] == p[j] && t[i] != t[j]) {
                                        pos[i] = j;
                                        pos[j] = i;
                                }
                        }
                }
                string ma = "";
                if (t[0] == 'b') { 
                        for (int i = 0; i < N; i ++) {
                                if (t[i] == 'a') {
                                        continue;
                                }
                                string now = "";
                                for (int j = i; j < N; j ++) {
                                        if (pos[j] >= i) {
                                                now += t[j];
                                        }
                                }
                                ma = max(ma, now);
                        }
                } else {
                        bool last = true;
                        for (int i = 0; i < N; i ++) {
                                if (t[i] == 'a') {
                                        ma += t[i];
                                        i = pos[i] - 1;
                                        last = false;
                                } else if (!last) {
                                        ma += t[i];
                                        last = true;
                                }
                        }
                }
                best.push_back(ma);
        }
        vector<string> now(2 * n + 1), next(2 * n + 1);
        now[0] = "";
        now[(int) best[0].size()] = best[0];
        int sum = (int) best[0].size();
        for (int i = 1; i < (int) best.size(); i ++) {
                int len = (int) best[i].size();
                sum += len;
                for (int j = 0; j <= sum - len; j ++) {
                        if (j != 0 && now[j] == "") continue;
                        next[j + len] = max(next[j + len], now[j] + best[i]);
                        next[j] = max(next[j], now[j]);
                }
                swap(now, next);
        }
        string ans = "";
        for (int j = 0; j <= 2 * n; j ++) {
                ans = max(ans, now[j]);
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 27392