package main

import "fmt"

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

	nums := make([]int, n)
	for i := range nums {
		fmt.Scan(&nums[i])
	}

	for i := 0; i < len(nums); i++ {
		var max int
		for j := 0; j < len(nums); j++ {
			if i == j {
				continue
			}
			n := nums[j]
			if max <= n {
				max = n
			}
		}
		fmt.Println(max)
	}
}
