use std::io;
use std::io::prelude::*;

fn main() {
    let mut s = String::new();
    let _ = io::stdin().read_to_string(&mut s).unwrap();
    let v: Vec<i32> = s.split('\n')
                       .filter(|x| !x.is_empty())
                       .map(|x| x.parse::<i32>().unwrap())
                       .collect();

    let max_in_all = v.iter().max().unwrap();

    for i in 0..v[1..].len() {
        let mut max = 0;
        let mut idx = 0;
        if max_in_all == &v[i + 1] {
            for j in &v[1..] {
                if idx != i {
                    let x = j.clone();
                    if max < x {
                        max = x
                    }
                }
                idx += 1
            }
            println!("{}", max);
        } else {
            println!("{}", max_in_all);
        }
    }
}
