#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    n = int(input())

    a = list()
    for i in range(n):
        a.append(int(input()))

    a_max = max(a)

    for i in range(n):
        if a[i] != a_max:
            print(a_max)
            continue

        tmp = a.copy()
        tmp.remove(a[i])
        print(max(tmp))


if __name__ == '__main__':
    main()
