function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);
    const numbers = args.slice(1, args.length).map(x => parseInt(x, 10));
    const sorted_numbers = numbers.slice().sort();

    // console.log(sorted_numbers);

    for (var i = 0; i < N; ++i) {
        var array = sorted_numbers.slice();
        array.splice(sorted_numbers.lastIndexOf(numbers[i]), 1);
        console.log(Math.max.apply(null, array));
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

// main(require('fs').readFileSync('test.txt', 'utf8'));
