if __name__ == "__main__":
    N = int(input())
    List = [int(input()) for x in range(N)]
    List_pre = []
    for i in range(N-1):
        List_pre = List
        List_pre.pop(i)
        print(max(List_pre))