def main():
    n = int(input())
    a_list = []
    for i in range(n):
        a = int(input())
        #[タグ、値]
        a_list.append([i,a])

    ans = sorted(a_list, key=lambda x:x[1])
    #print(ans)

    for i in range(n):
        #if 値 == max(ans)
        if ans[i][1] == max(ans[1]):
            #ansの最後から二番目の値
            print(ans[-2][1])
        else:
            print(ans[-1][1])

main()
