package main

import (
	"fmt"
	"sync"
)

func max(array []uint32, exceptInt int) uint32 {
	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)
	// }
	var mutex = &sync.Mutex{}
	var wg sync.WaitGroup
	for i := range An {
		wg.Add(1)
		go func(array []uint32, except int) {
			mutex.Lock()
			result[except] = max(An, except)
			mutex.Unlock()
			wg.Done()
		}(An, i)
	}

	wg.Wait()

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