import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int road = sc.nextInt();
		int[] floor = new int[road];
		int[] second = new int[road];
		for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		}
		Arrays.sort(floor);
		//max値を取り出す。
		for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		}
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int road = sc.nextInt();
		int[] floor = new int[road];
		int[] second = new int[road];
		for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		}
		Arrays.sort(floor);
		//max値を取り出す。
		for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		}
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int road = sc.nextInt();
		int[] floor = new int[road];
		int[] second = new int[road];
		for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		}
		Arrays.sort(floor);
		//max値を取り出す。
		for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		}
	} main {

		Scanner sc = new Scanner(System.in);

		int road = sc.nextInt();
		int[] floor = new int[road];
		int[] second = new int[road];
		for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		}
		Arrays.sort(floor);
		//max値を取り出す。
		for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int road = sc.nextInt(); road sc.nextInt() sc.nextInt sc int[] floor = new int[road]; floor new int[road] road int[] second = new int[road]; second new int[road] road for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		} int i = 0; int i = 0; i 0 i<road i road i++ i++ i {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		} {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		} floor[i] = sc.nextInt() floor[i] floor i sc.nextInt() sc.nextInt sc second[i] = floor[i] second[i] second i floor[i] floor i Arrays.sort(floor) Arrays.sort Arrays floor for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		} int i = 0; int i = 0; i 0 i<floor.length i floor.length floor floor.length i++ i++ i {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		} {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		} if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			} second[i] == floor[road-1] second[i] second i floor[road-1] floor road-1 road 1 {
					System.out.println(floor[road-2]);
			} System.out.println(floor[road-2]) System.out.println System.out System System.out floor[road-2] floor road-2 road 2 {
				System.out.println(floor[road-1]);
			} System.out.println(floor[road-1]) System.out.println System.out System System.out floor[road-1] floor road-1 road 1 String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int road = sc.nextInt();
		int[] floor = new int[road];
		int[] second = new int[road];
		for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		}
		Arrays.sort(floor);
		//max値を取り出す。
		for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		}
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int road = sc.nextInt();
		int[] floor = new int[road];
		int[] second = new int[road];
		for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		}
		Arrays.sort(floor);
		//max値を取り出す。
		for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		}
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int road = sc.nextInt();
		int[] floor = new int[road];
		int[] second = new int[road];
		for(int i = 0; i<road; i++) {
			floor[i] = sc.nextInt();
			second[i] = floor[i];
		}
		Arrays.sort(floor);
		//max値を取り出す。
		for(int i = 0; i<floor.length; i++) {
			if(second[i] == floor[road-1]) {
					System.out.println(floor[road-2]);
			}else {
				System.out.println(floor[road-1]);
			}
		}
	}
}