package main

import "fmt"

func inputSlice(inputNums int) []int {
	var ary []int
	for i := 0; i < inputNums; i++ {
		var in int
		fmt.Scan(&in)
		ary = append(ary, in)
	}
	return ary
}

func max(nums []int, exclude int) int {
	res := 0
	tmp := nums[exclude]
	nums[exclude] = 0
	for i := 0; i < len(nums); i++ {
		if res < nums[i] {
			res = nums[i]
		}
	}
	nums[exclude] = tmp
	return res
}

func main() {
	var n int
	fmt.Scan(&n)

	A := inputSlice(n)
	for i := 0; i < n; i++ {
		fmt.Println(max(A, i))
	}
}
