def main():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    MAX = max(a)
    for i in range(n):
        ans = MAX
        if a[i] == MAX:
            ans = max(a[:i] + a[i+1:]) if i != n - 1 else max(a[:i])
        print(ans)


if __name__ == '__main__':
    main()