NR==1{
    n=$1
    FS=RS
    RS="@"
}
NR>1{
    split($0, xs)
    top1 = xs[1]
    top2 = xs[2]
    for (i = 1; i <= n; ++i) {
        if (xs[i] > top1) {
            top2 = top1
            top1 = xs[i]
        } else if (xs[i] > top2) {
            top2 = xs[i]
        }
    }
    for (i = 1; i <= n; ++i) {
        print (xs[i] == top1) ? top2 : top1
    }
}
