#include <iostream>
#include<bits/stdc++.h>

using namespace std;

bool compare(string s1, string s2){
    int l1 = s1.length();
    int l2 = s2.length();
    for(int i=0; i<min(l1,l2); i++){
        if(s1[i] -'a' > s2[i]-'a')
            return true;
        else if(s1[i] -'a' < s2[i] -'a')
            return false;
    }
    if(l1 >= l2)
        return true;
    else
        return false;
}

string solve(string s){
    int l = s.length();
    int n = l/2;
    int a[n],b[n];
    int acount = 0, bcount = 0;
    for(int i=0; i<l; i++){
        if(s[i] =='a'){
            a[acount] = i;
            acount++;
        }
        else{
            b[bcount] = i;
            bcount++;
        }
    }
    vector<string> all;
    for(int i=0; i<n; i++){
        string t = "";
        for(int j=b[i]; j<a[i]; j++){
            if(s[j] =='b')
                t+="b";
        }
        t += s.substr(a[i], l - a[i]);
        all.push_back(t);
    }
    string ans = all[0];
    for(int i=0; i<n; i++){
        if(!compare(ans,all[i]))
            ans = all[i];
    }
    return ans;
}


int main()
{

    int N;
    string S;
    cin>>N;
    cin>>S;
    vector<pair<int,int> > segments;
    int partials = 0;
    int prev = 0;
    bool check = false;
    for(int i=0; i<2*N; i++){
        if(S[i] == 'a')
            partials++;
        else
            partials--;
        if(partials == 0){
            if(S[i] == 'a'){
                segments.push_back(make_pair(prev, i));
                check = true;
            }
            prev = i+1;
        }
    }



    int l = segments.size();
    vector<string> subanswers;
    for(int i=0; i<l; i++){
        subanswers.push_back(solve(S.substr(segments[i].first, segments[i].second - segments[i].first + 1)));
    }


    if(check){
        string output = "";
        for(int i=0; i<l; i++){
            bool use = true;
            string s1 = subanswers[i];
            for(int j=i; j<l; j++){
                string s2 = subanswers[j];
                if(!compare(s1,s2))
                    use = false;

            }
            if(use){
                output += s1;
            }


        }
        cout<<output;
        int last = segments[l-1].second;
        int acount =0;
        int bcount = 0;
        int current = 0;
        int repeats = 0;
        for(int i= last +1; i<2*N ; i++){
            if(current==0){
                if(S[i]=='a'){
                    acount++;
                    current = acount;
                    repeats += 1;
                }
                else
                    bcount++;
            }
            else{
                if(S[i]=='b'){
                    bcount++;
                    if(bcount ==current)
                        current = 0;
                }
                else
                    acount++;
            }

        }
        for(int i=0; i<repeats; i++){
            cout<<"ab";
        }
        cout<<endl;

    }

    else{
        int acount =0;
        int bcount = 0;
        int current = 0;
        int repeats = 0;
        for(int i= 0; i<2*N ; i++){
            if(current==0){
                if(S[i]=='a'){
                    acount++;
                    current = acount;
                    repeats += 1;
                }
                else
                    bcount++;
            }
            else{
                if(S[i]=='b'){
                    bcount++;
                    if(bcount ==current)
                        current = 0;
                }
                else
                    acount++;
            }

        }

        for(int i=0; i<repeats; i++){
            cout<<"ab";
        }
        cout<<endl;

    }




    return 0;
}


Measured memory_bytes: 11904