package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	A := make([]int, n)
	for i:=0;i<n;i++ {
		var m int
		fmt.Scan(&m)
		A[i] = m
	}
	ans := make([]int, n)
	for i, _:= range A {
		B := []int{}
		for j, _:= range A {
			if j == i { continue }
			B = append(B, A[j])
		}
		sort.Ints(B)
		ans[i] = B[len(B)-1]
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}