
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n];
        int[] b = new int [n];
        for(int i = 0; i < n ; i++){
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        }
        Arrays.sort(b);
        
        for(int i = 0; i < n; i++){
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        }
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n];
        int[] b = new int [n];
        for(int i = 0; i < n ; i++){
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        }
        Arrays.sort(b);
        
        for(int i = 0; i < n; i++){
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        }
    }
} Main public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n];
        int[] b = new int [n];
        for(int i = 0; i < n ; i++){
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        }
        Arrays.sort(b);
        
        for(int i = 0; i < n; i++){
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        }
    } main {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n];
        int[] b = new int [n];
        for(int i = 0; i < n ; i++){
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        }
        Arrays.sort(b);
        
        for(int i = 0; i < n; i++){
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        }
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] a = new int[n]; a new int[n] n int[] b = new int [n]; b new int [n] n for(int i = 0; i < n ; i++){
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        } {
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        } a[i] = stdIn.nextInt() a[i] a i stdIn.nextInt() stdIn.nextInt stdIn b[i] = a[i] b[i] b i a[i] a i Arrays.sort(b) Arrays.sort Arrays b for(int i = 0; i < n; i++){
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        } {
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        } System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]) System.out.println System.out System System.out b[n - 1] == a[i] ? b[n - 2] : b[n - 1] b[n - 1] == a[i] b[n - 1] b n - 1 n 1 a[i] a i b[n - 2] b n - 2 n 2 b[n - 1] b n - 1 n 1 String[] args args

import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n];
        int[] b = new int [n];
        for(int i = 0; i < n ; i++){
            a[i] = stdIn.nextInt();
            b[i] = a[i];
        }
        Arrays.sort(b);
        
        for(int i = 0; i < n; i++){
            System.out.println(b[n - 1] == a[i] ? b[n - 2] : b[n - 1]);
        }
    }
}