#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let n = read_i64() as usize;
    let ss: Vec<u8> = read_line().bytes().collect();
    let mut xs = vec![0; 2*n+1];
    for i in 0..2*n {
        xs[i+1] = xs[i] + tf!(ss[i] == b'a', 1, -1);
    }
    let ys = {
        let mut ys: Vec<Vec<u8>> = vec![];
        let mut buf = vec![];
        for i in 0..2*n+1 {
            if i == 2*n || xs[i] == 0 {
                if ! buf.is_empty() {
                    ys.push(buf.clone());
                    buf.clear();
                }
            }
            if i != 2 * n {
                buf.push(ss[i]);
            }
        }
        ys
    };
    let zs: Vec<Vec<u8>> = ys.iter().map(|y| {
        let mut ai = vec![];
        let mut bi = vec![];
        let mut si = vec![];
        for (i,&c) in y.iter().enumerate() {
            match c {
                b'a' => {
                    si.push(ai.len());
                    ai.push(i);
                }
                b'b' => {
                    si.push(bi.len());
                    bi.push(i);
                }
                _ => {
                    panic!();
                }
            }
        }
        let mut res: Vec<u8> = vec![];
        match y[0] {
            b'a' => {
                let mut prev = b'b';
                let mut valid: Vec<bool> = vec![true; y.len()];
                for (i,&c) in y.iter().enumerate() {
                    if ! valid[i] {
                        continue;
                    }
                    if c == prev {
                        match c {
                            b'a' => {
                                valid[bi[si[i]]] = false;
                            }
                            b'b' => {
                                valid[ai[si[i]]] = false;
                            }
                            _ => {
                                panic!();
                            }
                        }
                    }
                    else {
                        res.push(c);
                        prev = c;
                    }
                }
            }
            b'b' => {
                let mut valid = vec![true; y.len()];
                for i in 0..y.len() {
                    if ! valid[i] {
                        continue;
                    }
                    if y[i] == b'b' {
                        let mut buf = vec![];
                        for k in i..y.len() {
                            if ! valid[k] {
                                continue;
                            }
                            buf.push(y[k]);
                            if res < buf {
                                res = buf.clone();
                            }
                        }
                        valid[ai[si[i]]] = false;
                    }
                }
            }
            _ => {
                panic!();
            }
        }
        res
    }).collect();
    //eprintln!("{:?}", ys);
    //eprintln!("{:?}", zs);
    let mut res = vec![];
    for z in zs.iter().rev() {
        let mut buf = z.clone();
        for &c in &res {
            buf.push(c);
        }
        if res < buf {
            res = buf.clone();
        }
    }
    println!("{}", std::str::from_utf8(&res).unwrap());
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352