function Main(input){
	var tmp = input.split('\n');
  var N = Number(tmp.shift());
  tmp.pop();
  var D = tmp.map(a=>Number(a));
  var arr = [];
  for(var i=0;i<N;i++){
    var tmp = D.filter((a,b,c)=>b!=i);
    arr.push(tmp.reduce((a,b)=>a>b?a:b));
  }
  for(var i=0;i<N;i++){
    console.log(arr[i]);
  }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));