// Created by Alphagocc
#include<bits/stdc++.h>

#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
// namespace IO 
namespace IO
{
template <typename T>
void __RI(T &x)
{
    int ch = getchar(), neg = 1;
    x = 0;
    for (; !(isdigit(ch) || ch == '-' || ch == EOF); ch = getchar())
        ;
    if (unlikely(ch == EOF)) return;
    if (ch == '-') neg = -1;
    for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    x *= neg;
}
void R(int &x) { __RI(x); }
void R(int64_t &x) { __RI(x); }
void R(double &x) { scanf("%lf", &x); }
void R(char &x) { scanf("%c", &x); }
void R(char *x) { scanf("%s", x); }
void R(std::string &x) { std::cin >> x; }
template <typename T1, typename T2>
void R(std::pair<T1, T2> &x)
{
    R(x.first);
    R(x.second);
}
template <typename T>
void R(std::vector<T> &x)
{
    for (auto &i : x) { R(i); }
}
template <typename T>
void R(T &x)
{
    std::cin >> x;
}
template <typename T, typename... Args>
void R(T &x, Args &... args)
{
    R(x), R(args...);
}
char space = ' ';
template <typename T>
void __WI(T x)
{
    if (unlikely(x == 0)) putchar('0');
    if (x < 0) putchar('-'), x = -x;
    char ch[ 64 ];
    int  pos = 0;
    while (x) ch[ pos++ ] = x % 10 + 48, x /= 10;
    while (pos) putchar(ch[ --pos ]);
}
void W() {}
void W(const int &x) { __WI(x); }
void W(const int64_t &x) { __WI(x); }
void W(const double &x) { printf("%lf",static_cast<double>(x)); }
void W(const char &x) { putchar(x); }
void W(const std::string &x) { printf("%s", x.c_str()); }
template <typename T1, typename T2>
void W(const std::pair<T1, T2> &x)
{
    W(x.first);
    W(space);
    W(x.second);
}
template <typename T>
void W(const std::vector<T> &x)
{
    for (auto it = x.cbegin();it != x.cend(); it++)
    {
        W(*it);
        W(space);
    }
    W('\n');
}
template <typename T>
void W(const T &x)
{
    std::cout << x;
}
template <typename T, typename... Args>
void W(const T &x,const Args &... args)
{
    W(x), W(space), W(args...);
}
template <typename... Args>
void WL(const Args &... args)
{
    W(args...), W('\n');
}
}; // namespace IO

using namespace std;

#define REP(i, x, y) for (int i = x;i < y; i++)

const int8_t  INFC = 0x3f;
const int16_t INFS = 0x3f3f;
const int32_t INF  = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 6.1e3;

int    pos[ 6010 ], a[ 3010 ], b[ 3010 ];
string dp[ 6010 ];

int main()
{
    int    n;
    string s, ans;
    IO::R(n, s);
    s.insert(s.begin(),' ');
    for (int i = 1; i <= n * 2; i++)
        if (s[ i ] == 'a')
            a[ ++a[ 0 ] ] = i, pos[ i ] = a[ 0 ];
        else
            b[ ++b[ 0 ] ] = i, pos[ i ] = b[ 0 ];
    for (int i = n; i >= 1; i--)
    {
        if (a[ i ] < b[ i ])
        {
            int k = i;
            for (int j = a[ i ] + 1; j < b[ i ]; j++) k = max(k, pos[ j ]);
            dp[ i ] = "ab" + dp[ k + 1 ];
        }
        else
        {
            int k = i;
            while (k < n && b[ k + 1 ] < a[ k ]) k++;
            for (int j = b[ i ]; j <= n * 2; j++)
                if (i <= pos[ j ] && pos[ j ] <= k) dp[ i ] += s[ j ];
            dp[ i ] += dp[ k + 1 ];
        }
        dp[ i ] = max(dp[ i ], dp[ i + 1 ]);
        ans     = max(ans, dp[ i ]);
    }
    IO::WL(ans);
    return 0;
}

Measured memory_bytes: 14592