<?php
fscanf(STDIN,"%d",$N);

$a_list = array();
for($i=0;$i<$N;$i++){
    $a_list[] = trim(fgets(STDIN));
}

for($j=0;$j<$N;$j++){
    $tmp = $a_list[$j];
    $a_list[$j] = -1000000;

    $maxdesu =   max($a_list);

    $a_list[$j] = $tmp;

    echo $maxdesu."\n";

}

