function main(input) {
  var a = input.split("\n");
  var max = 0;
  var next = 0;
 
  for (var i = 0; i < a.length; i++) {
    if (parseInt(max, 10) < parseInt(a[i], 10)) {
      max = a[i];
      next = max;
    }
  }
 
  for (var j = 1; j < a.length; j++) {
    if (max == a[j]) {
      console.log(next);
    } else {
      console.log(max);
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));