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


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

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

    a_sorted = sorted(a, reverse=True)

    for i in range(n):
        index = a_sorted.index(a[i])
        if index == 0:
            print(a_sorted[index + 1])
            continue

        print(a_sorted[0])


if __name__ == '__main__':
    main()
