import java.util.Scanner;

public class Main {
    static int N;
    static double[] a;
    static double first = 0;
    static double second = 0;


    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new double[N];
        for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        }
        scanner.close();
    }


    public static void main(String[] args) {
        init();

        for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static int N;
    static double[] a;
    static double first = 0;
    static double second = 0;


    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new double[N];
        for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        }
        scanner.close();
    }


    public static void main(String[] args) {
        init();

        for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        }
    }
} Main static int N; N static double[] a; a static double first = 0; first 0 static double second = 0; second 0 private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new double[N];
        for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        }
        scanner.close();
    } init {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new double[N];
        for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        }
        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) N = scanner.nextInt() N scanner.nextInt() scanner.nextInt scanner a = new double[N] a new double[N] N for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        } {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        } double input = scanner.nextDouble(); input scanner.nextDouble() scanner.nextDouble scanner a[i] = input a[i] a i input if(first < input) {
                second = first;
                first = input;
                continue;
            } first < input first input {
                second = first;
                first = input;
                continue;
            } second = first second first first = input first input continue; if(second < input) {
                second = input;
            } second < input second input {
                second = input;
            } second = input second input scanner.close() scanner.close scanner public static void main(String[] args) {
        init();

        for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        }
    } main {
        init();

        for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        }
    } init() init for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        } {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        } if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            } a[i] == first a[i] a i first {
                System.out.println((int) second);
            } System.out.println((int) second) System.out.println System.out System System.out (int) second {
                System.out.println((int) first);
            } System.out.println((int) first) System.out.println System.out System System.out (int) first String[] args args public class Main {
    static int N;
    static double[] a;
    static double first = 0;
    static double second = 0;


    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new double[N];
        for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        }
        scanner.close();
    }


    public static void main(String[] args) {
        init();

        for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        }
    }
} public class Main {
    static int N;
    static double[] a;
    static double first = 0;
    static double second = 0;


    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new double[N];
        for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        }
        scanner.close();
    }


    public static void main(String[] args) {
        init();

        for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    static int N;
    static double[] a;
    static double first = 0;
    static double second = 0;


    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new double[N];
        for(int i = 0; i < N; i++) {
            double input = scanner.nextDouble();
            a[i] = input;
            if(first < input) {
                second = first;
                first = input;
                continue;
            }
            if(second < input) {
                second = input;
            }
        }
        scanner.close();
    }


    public static void main(String[] args) {
        init();

        for(int i = 0; i < N; i++) {
            if(a[i] == first) {
                System.out.println((int) second);
            } else {
                System.out.println((int) first);
            }
        }
    }
}
