package main

import (
	"fmt"
)

func max(array []uint32, except uint32) uint32 {
	exceptInt := int(except)
	var maxValue uint32
	var i int

	maxValue = 0
	for i = 0; i < len(array); i++ {

		if exceptInt == i {
			continue
		}

		if maxValue < array[i] {
			maxValue = array[i]
		}
	}

	return maxValue

}

func main() {
	var N uint32
	fmt.Scan(&N)

	An := make([]uint32, N)
	result := make([]uint32, N)

	var i uint32
	for i = 0; i < N; i++ {
		fmt.Scan(&An[i])
	}

	for i = 0; i < N; i++ {
		result[i] = max(An, i)
	}

	for i = 0; i < N; i++ {
		fmt.Println(result[i])
	}
}
