function Main(input){
	var tmp = input.split('\n');
  var N = Number(tmp.shift());
  tmp.pop();
  var D = tmp.map(a=>Number(a));
  var max1 = D.indexOf(Math.max.apply(null,D));
  var max2 = D.indexOf(Math.max.apply(null,D.filter((a,b,c)=>b!=max1)));
  for(var i=0;i<N;i++){
    if(i==max1){
      console.log(D[max2]);
    }else{
      console.log(D[max1]);
    }
  }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));