#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x <<": " << (x) << endl
//Ã�Â¥Ã¯Â¿Â½Ã�Â¨Ã�Â¦Ã�Â¯Ã¯Â¿Â½Ã�Â¤Ã�Â¸Ã�ÂªÃ�Â¥Ã¯Â¿Â½Ã�Â½Ã�Â¦Ã¯Â¿Â½Ã�Â°Ã�Â§Ã¯Â¿Â½Ã¯Â¿Â½Ã�Â¥Ã¯Â¿Â½Ã�Â¥Ã�Â¥Ã¯Â¿Â½Ã�Â£Ã�Â¥Ã�Â¤Ã¯Â¿Â½Ã�Â¦Ã¯Â¿Â½Ã�Â§Ã�Â¨Ã�Â¡Ã¯Â¿Â½Ã�Â¤Ã�Â¸Ã¯Â¿Â½Ã�Â¦Ã�Â¬Ã�Â¡Ã�Â¯Ã�Â¼Ã¯Â¿Â½Ã�Â¥Ã¯Â¿Â½Ã�ÂºÃ�Â¥Ã¯Â¿Â½Ã�Â£Ã�Â¥Ã�Â¤Ã¯Â¿Â½Ã�Â¦Ã¯Â¿Â½Ã�Â§Ã�Â¨Ã�Â¡Ã¯Â¿Â½Ã�Â¤Ã�Â¸Ã¯Â¿Â½Ã�Â¦Ã�Â¬Ã�Â¡Ã�Â£Ã¯Â¿Â½Ã¯Â¿Â½Ã�Â§Ã¯Â¿Â½Ã�Â¶Ã�Â¥Ã¯Â¿Â½Ã¯Â¿Â½Ã�Â¥Ã�Â°Ã�Â±Ã�Â¥Ã¯Â¿Â½Ã�Â¯Ã�Â¤Ã�Â»Ã�Â¥Ã�Â¥Ã�Â¿Ã�Â«Ã�Â©Ã¯Â¿Â½Ã¯Â¿Â½Ã�Â¥Ã�Â¾Ã¯Â¿Â½Ã�Â§Ã¯Â¿Â½Ã�Â¥Ã�Â¦Ã¯Â¿Â½Ã�Â¯Ã�Â¥Ã¯Â¿Â½Ã�ÂªÃ�Â¤Ã�Â¸Ã�ÂªÃ�Â¥Ã¯Â¿Â½Ã�Â°Ã�Â¦Ã¯Â¿Â½Ã�Â¹Ã�Â¦Ã�Â®Ã�ÂµÃ�Â©Ã¯Â¿Â½Ã¯Â¿Â½Ã�Â¨Ã�Â¯Ã�Â¯Ã�Â¤Ã�ÂºÃ¯Â¿Â½
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#ifdef LOCAL
#define see(x) cout  << #x << ": " << (x) << endl
#endif
#ifndef LOCAL
#define see(x)
#endif


#define rep(n) for(int _ = 0; _ != (n); ++_)
//#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define Rng(i, n) for(int i = 0; i != (n); ++i)
#define rng(i, a, b) for(int i = (a); i < (b); ++i)
#define rno(i, b) for(int i = 0; i<(b); ++i)
#define rnc(i, a, b) for(int i = (a); i<=(b); ++i)
#define RNG(i, a) for(auto &i: (a))
#define dwn(i, r, l) for(int i = (r); i>=(l); i--)

namespace std {
    template<class T>
    T begin(std::pair<T, T> p)
    {
        return p.first;
    }
    template<class T>
    T end(std::pair<T, T> p)
    {
        return p.second;
    }
}


#if __cplusplus < 201402L
template<class Iterator>
std::reverse_iterator<Iterator> make_reverse_iterator(Iterator it)
{
    return std::reverse_iterator<Iterator>(it);
}
#endif

template<class Range>
std::pair<std::reverse_iterator<decltype(begin(std::declval<Range>()))>, std::reverse_iterator<decltype(begin(std::declval<Range>()))>> make_reverse_range(Range &&r)
{
    return std::make_pair(make_reverse_iterator(::begin(r)), make_reverse_iterator(::end(r)));
}

#define RRNG(x, cont) for (auto &x: make_reverse_range(cont))



template<class T> int sign(const T &a) { return a == 0 ? 0 : a > 0 ? 1 : -1; }
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> void Min(T &a, const T &b){ a = min(a, b); }
template<class T> void Max(T &a, const T &b){ a = max(a, b); }

template<typename T> void println(const T &t) { cout << t << '\n'; }
template<typename T, typename ...Args> void println(const T &t, const Args &...rest) { cout << t << ' '; println(rest...); }

template<typename T> void print(const T &t) { cout << t << ' '; }

template<typename T, typename ...Args> void print(const T &t, const Args &...rest) { cout << t; print(rest...); }

// this overload is chosen when there's only one argument
template<class T> void scan(T &t) { cin >> t; }
template<class T, class ...Args> void scan(T &a, Args &...rest) { cin >> a; scan(rest...); }

using ll = long long;
using ull = unsigned long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pip = pair<int, pii>;
using szt = size_t;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using pli = pair<ll,int>;
using wg = vector<vpii>; //weighted graph

int cas;
const double pi = acos(-1);
ll mod = 1e9 + 7;

template<class T>
inline void add_mod(T &a, const T &b) {
    a += b;
    if (a >= mod) a -= mod;
}
template<class T>
void sub_mod(T &a, const T &b){
    a -= b;
    if (a < 0) a += mod;
}
auto bo=[](int x){ //Ã�Â¤Ã�ÂºÃ¯Â¿Â½Ã�Â¨Ã�Â¿Ã¯Â¿Â½Ã�Â¥Ã¯Â¿Â½Ã�Â¶Ã�Â¨Ã�Â¾Ã¯Â¿Â½Ã�Â¥Ã¯Â¿Â½Ã�Âº
    bitset<5> a(x);
    cout << a << endl;
};



mat operator*(const mat &a, const mat &b) {
    mat c(a.size(), vec(b[0].size()));
    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < a[0].size(); j++) {
            if (a[i][j]) { // optimization for sparse matrix
                for (int k = 0; k < b[0].size(); k++) {
                    add_mod(c[i][k], a[i][j] * b[j][k] % mod);
                }
            }
        }
    }
    return c;
}

vec operator*(const mat &a, const vec &b) {
    vec c(a.size());
    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < a[0].size(); j++) {
            add_mod(c[i], a[i][j] * b[j] % mod);
        }
    }
    return c;
}

mat pow(mat a, ull n) {
    mat res(a.size(), vec(a[0].size()));
    for (int i = 0; i < a.size(); i++) {
        res[i][i] = 1;
    }
    while (n) {
        if (n & 1) {
            res = res * a;
        }
        a = a * a;
        n >>= 1;
    }
    return res;
}

std::ostream& operator<<(std::ostream& os, __int128 T) {
    if (T<0) os<<"-";
    if (T>=10 ) os<<T/10;
    if (T<=-10) os<<(-(T/10));
    return os<<( (int) (T%10) >0 ? (int) (T%10) : -(int) (T%10) ) ;
}

__int128 LPOW(__int128 x, ll n) {
    __int128 res = 1;
    for (; n; n /= 2, x *= x, x %= mod) {
        if (n & 1) {
            res *= x;
            res %= mod;
        }
    }
    return res;
}

ll POW(ll x, ll n){
    ll res = 1;
    for (; n; n /= 2, x *= x, x %= mod) {
        if (n & 1) {
            res *= x;
            res %= mod;
        }
    }
    return res;
}


ll INV(ll x) {
    return POW(x, mod - 2);
}

ll inv(ll x){
//    see(x);
    return x == 1? 1: (mod - mod/x * inv(mod%x) % mod);
}



// 2D rotation
void rotate(double &x, double &y, double theta) {
    double tx = cos(theta) * x - sin(theta) * y;
    double ty = sin(theta) * x + cos(theta) * y;
    x = tx, y = ty;
}
namespace bit {
    const int BIT_N = 1e5 + 5;

    int bit[BIT_N];
    void init(int n){
        rng(i, 1, n+1) bit[i] = 0;
    }
    int sum(int x) {
        int res = 0;
        while (x) {
            res += bit[x];
            x -= x & -x;
        }
        return res;
    }

    int sum(int l, int r) {
        if (l > r) return 0;
        return sum(r) - sum(l - 1);
    }

    void add(int x, int v, int n) {
        while (x <= n) {
            bit[x] += v;
            x += x & -x;
        }
    }
}


namespace util{
    int len(ll x){return snprintf(nullptr, 0, "%lld", x);}
    vi get_d(ll x){
        vi res;
        while(x) {
            res.pb(x%10);
            x /= 10;
        }
        reverse(all(res));
        return res;
    }
    template <class T> T parity(const T &a){
        return a & 1;
    }
    template <class T>
    void out (const vector<T> &a){
        std::copy(a.begin(), a.end(), std::ostream_iterator<T>(std::cout, ", "));
        cout << endl;
    };
}

using namespace util;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using order_statistic_tree = __gnu_pbds::tree<
        int,
        __gnu_pbds::null_type,
        greater<int>,
        __gnu_pbds::rb_tree_tag,
        __gnu_pbds::tree_order_statistics_node_update>;


const ll LINF = LLONG_MAX/10;
const int INF = INT_MAX/10;
const int M = 3000 + 5;


const int N = 5e5+5;


int m[1005][1005];

int main() {
    // Single Cut of Failure taught me
    cout << std::fixed; //
    cout << setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


#ifdef LOCAL
    freopen("main.in", "r", stdin);
//    freopen("main.out", "w", stdout);
#endif

    int n;
    scan(n);
    string s;
    scan(s);
    vi a, b;
    rng(i, 0, s.size()){
        if(s[i]=='a') a.pb(i);
        else b.pb(i);
    }
    int ma = 0;
    rng(i, 0, n){
        Max(ma, a[i] - b[i]);
    }
    if(ma == 0){
        int t = 0;
        string ans;
        rng(i, 0, n){
            if(a[i] >= t){
                ans += "ab";
                t = b[i]+1;
            }
        }
        println(ans);
    }
    else{
        vector<pair<string,pii>> x;
        auto cmp =[](pair<string,pii> x, pair<string,pii> y){
            return x.first > y.first || (x.first == y.first && x.second < y.second);
        };
        rng(i, 0, n){
            if(b[i] < a[i]) {
                vector<int> tmp;
                tmp.pb(a[i]);
                tmp.pb(b[i]);
                int j = i+1;
                int t = a[i];
                while (j < n && b[j] < t) {
                    tmp.pb(b[j]);
                    tmp.pb(a[j]);
                    t = a[j];
                    ++j;
                }
                sort(all(tmp));
                string str;
                RNG(pos, tmp) str += s[pos];
                x.eb(str, pii{b[i], t+1});
            }
        }
        sort(all(x), cmp);
        int pos = 0;
        string ans;
        RNG(i, x){ // x中不存在某个串是另一个串的 proper prefix
//            println(i.first, i.second.first, i.second.second);
            if(i.second.first >= pos){
                ans += i.first;
                pos = i.second.second;
            }
        }
        rng(i, 0, n){
            if(a[i] >= pos){
                ans += "ab";
                pos = b[i];
            }
        }
        println(ans);
    }


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 17280