def main():
    n = input()
    aa = []
    for _ in xrange(n):
        aa.append(input())
    bb = sorted(aa)
    b0, b1 = bb[-1], bb[-2]
    for a in aa:
        if a < b0:
            print b0
        else:
            print b1
 
 
if __name__ == '__main__':
    main()