<?php

fscanf(STDIN, "%d", $n);
$A = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d", $a);
    $A[] = $a;
}

for ($i = 0; $i < $n; ++$i) {
    $tmp = $A;
    array_splice($tmp, $i, 1);
    echo max($tmp), PHP_EOL;
}
