#include <bits/stdc++.h>
// {{{ Definitions
#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define FERR(s) freopen(s, "w", stderr)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define dputs(s) fprintf(stderr, s"\n")
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;
// }}}
// {{{ Modular
namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular
// }}}
// {{{ Base
namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
// }}}
using namespace Base;

#define MAX_N 6007

int N, tot;
int len[MAX_N];
char s[MAX_N], ans[MAX_N][MAX_N], res[MAX_N], tmp[MAX_N];

inline bool sml(char *s1, int l1, char *s2, int l2) { //s1<s2
    int l = std::min(l1, l2);
    Rep(i, l)
        if (s1[i] < s2[i]) return true;
        else if (s1[i] > s2[i]) return false;
    return l1 < l2;
}

int rk[MAX_N];
bool vis[MAX_N];
inline void solve(int l, int r) {
    // debug("%d %d\n", l, r);
    ++tot;
    int &L = len[tot];
    L = 0;
    if (s[l] == 'a') {
        int nb = 0, na = 0, cnt = 0;
        rep(i, l, r) {
            if (s[i] == 'a') {
                na++;
                int tmp = na;
                while (i < r) {
                    ++i;
                    if (s[i] == 'b') nb++;
                    else na++;
                    if (nb == tmp) break;
                }
                cnt++;
            } else {
                nb++;
            }
        }
        if (!cnt) return --tot, void();
        L = cnt << 1;
        Rep(i, cnt) ans[tot][i * 2 - 1] = 'a', ans[tot][i * 2] = 'b';
    } else {
        int k = r - l + 1 >> 1, na = 0, nb = 0;
        rep(i, l, r) {
            s[i] == 'a' ? rk[i] = ++na : rk[i] = ++nb;
        }
        Rep(i, k) {
            int L2 = 0;
            rep(j, l, r) {
                if (rk[j] >= i) tmp[++L2] = s[j];
            }
            if (sml(ans[tot], L, tmp, L2)) {
                L = L2;
                Rep(j, L) ans[tot][j] = tmp[j];
            }
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    FIN("c.in");
    FOUT("c.out");
    FERR("c.log");
#endif
    read(N);
    N <<= 1;
    scanf("%s", s + 1);
    int cnt = 0, las = 1;
    Rep(i, N) {
        cnt += s[i] == 'a' ? 1 : -1;
        if (cnt == 0) {
            solve(las, i);
            las = i + 1;
        }
    }
    // Rep(i, tot) {
        // debug("%d:\n", i);
        // Rep(j, len[i]) debug("%c", ans[i][j]); dputs("");
    // }
    // dputs("----");
    int top = 0;
    IRep(i, tot) {
        int tl = 0;
        Rep(j, len[i]) tmp[j] = ans[i][j];
        Rep(j, top) tmp[j + len[i]] = res[j];
        tmp[top + len[i] + 1] = 0;
        // debug("%s %s\n", tmp + 1, res + 1);
        if (!sml(tmp, top + len[i], res, top)) {
            top += len[i];
            Rep(j, top) res[j] = tmp[j];
        }
    }
    Rep(i, top) putchar(res[i]); puts("");
    return 0;
}


Measured memory_bytes: 14924