package main

import (
        "fmt"
)

func solution(n int, a []int) []int {
        out := make([]int, 0, n)
        for i := 0; i < n; i++ {
                hi := -1 << 31
                for j := 0; j < n; j++ {
                        if i != j {
                                hi = max(hi, a[j])
                        }
                }
                out = append(out, hi)
        }
        return out
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, 0, n)
        for i := 0; i < n; i++ {
                t := 0
                fmt.Scan(&t)
                a = append(a, t)
        }
        for _, v := range solution(n, a) {
                fmt.Println(v)
        }
}