import java.util.*;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
        int[] src = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			src[i] = map[i];
		}

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

		Arrays.sort(map);
		
		for (int i = 0; i < N; i++) {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		}
		
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
        int[] src = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			src[i] = map[i];
		}

		Arrays.sort(map);
		
		for (int i = 0; i < N; i++) {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		}
		
    } main {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
        int[] src = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			src[i] = map[i];
		}

		Arrays.sort(map);
		
		for (int i = 0; i < N; i++) {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		}
		
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] map = new int[N]; map new int[N] N int[] src = new int[N]; src new int[N] N for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			src[i] = map[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			map[i] = sc.nextInt();
			src[i] = map[i];
		} {
			map[i] = sc.nextInt();
			src[i] = map[i];
		} map[i] = sc.nextInt() map[i] map i sc.nextInt() sc.nextInt sc src[i] = map[i] src[i] src i map[i] map i Arrays.sort(map) Arrays.sort Arrays map for (int i = 0; i < N; i++) {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		} {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		} if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			} src[i] == map[N-1] src[i] src i map[N-1] map N-1 N 1 {
				System.out.println(map[N-2]);
			} System.out.println(map[N-2]) System.out.println System.out System System.out map[N-2] map N-2 N 2 {
				System.out.println(map[N-1]);
			} System.out.println(map[N-1]) System.out.println System.out System System.out map[N-1] map N-1 N 1 String[] args args public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
        int[] src = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			src[i] = map[i];
		}

		Arrays.sort(map);
		
		for (int i = 0; i < N; i++) {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		}
		
    }
} public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
        int[] src = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			src[i] = map[i];
		}

		Arrays.sort(map);
		
		for (int i = 0; i < N; i++) {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		}
		
    }
} Main
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
        int[] src = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			src[i] = map[i];
		}

		Arrays.sort(map);
		
		for (int i = 0; i < N; i++) {
			if (src[i] == map[N-1]) {
				System.out.println(map[N-2]);
			} else {
				System.out.println(map[N-1]);
			}	
		}
		
    }
}