import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    }
} Main public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    } main {
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] a = new int[200010]; a new int[200010] 200010 for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            a[i] = scan.nextInt();
        } {
            a[i] = scan.nextInt();
        } a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan int ma = 0; ma 0 for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        } int i=1; int i=1; i 1 i<n i n i++ i++ i {
            if(a[ma] < a[i]){
                ma = i;
            }
        } {
            if(a[ma] < a[i]){
                ma = i;
            }
        } if(a[ma] < a[i]){
                ma = i;
            } a[ma] < a[i] a[ma] a ma a[i] a i {
                ma = i;
            } ma = i ma i int temp; temp if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        } ma > 0 ma 0 {
            temp = 0;
        } temp = 0 temp 0 {
            temp = ma + 1;
        } temp = ma + 1 temp ma + 1 ma 1 for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        } {
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        } if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            } ma == i ma i {
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            } for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                } int j=0; int j=0; j 0 j<n j n j++ j++ j {
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                } {
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                } if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    } ma != j ma j {
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    } if(a[temp] < a[j]){
                            temp = j;
                        } a[temp] < a[j] a[temp] a temp a[j] a j {
                            temp = j;
                        } temp = j temp j System.out.println(a[temp]) System.out.println System.out System System.out a[temp] a temp {
                System.out.println(a[ma]);
            } System.out.println(a[ma]) System.out.println System.out System System.out a[ma] a ma String[] args args public class Main{
    public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    }
} public class Main{
    public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    }
}
