package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	var as []int
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		as = append(as, a)
	}

	sortedAS := as
	sort.Sort(sort.IntSlice(sortedAS))

	for i := 0; i < n; i++ {
		for i := 1; i <= n; i++ {
			if as[i] == sortedAS[n-i] {
				continue
			}
			fmt.Println(sortedAS[n-1])
			break
		}
	}
}
