function Main(input){
  inputs=input.split("\n");
  numbers=inputs.filter((x,i)=>i!==0&&x!="");
  [...Array(parseInt(inputs[0])+1)].reduce((_,x,index)=>{
    max=numbers.filter((_,i)=>i!=index-1).reduce((a,b)=>a>b?a:b);
    console.log(max);
  });
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
