def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    for _ in range(n):
        tmp = a.pop(0)
        print(max(a))
        a.append(tmp)
   
    
if __name__ == '__main__':
    main()