<?php
$n = trim(fgets(STDIN));
$a = [];
for ($i = 0; $i < $n; $i++) {
    $a[$i] = trim(fgets(STDIN));
}

$a_tmp = [];
for ($j = 0; $j < $n; $j++) {
    $a_tmp = $a;
    unset($a_tmp[$j]);
    rsort($a_tmp);
    echo $a_tmp[0] . PHP_EOL;
}
