import java.util.*;

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] temp = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
            temp[i] = a[i];
        }
        Arrays.sort(temp);
        int max = temp[temp.length - 1];
        for(int i = 0;i < n;i++){
            if (max == a[i]) {
                System.out.println(temp[temp.length - 2]);
                continue;
            }
            System.out.println(max);
        }
    }
}