import sys
input = sys.stdin.readline
n = int(input())

s = [int(input()) for i in range(n)]

maxNum = max(s)

def func(n):
  if maxNum < n:
    return str(maxNum)
  else:
    list = s[:]
    list.remove(n)
    return str(max(list))


def main():
  print('\n'.join(map(func,s)))


if __name__ == '__main__':
    main()