import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Map.Entry; Entry java.util.Map import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	}
} Main public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	} main {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n   = Integer.parseInt(scanner.nextLine()); n Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner int[] list = new int[n]; list new int[n] n int[] ans  = new int[n]; ans new int[n] n for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		} {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		} list[i] = Integer.parseInt(scanner.nextLine()) list[i] list i Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner ans[i]  = list[i] ans[i] ans i list[i] list i Arrays.sort(list) Arrays.sort Arrays list for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		} {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		} if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			} list[n - 1] != ans[i] list[n - 1] list n - 1 n 1 ans[i] ans i {

				System.out.println(list[n - 1]);

			} System.out.println(list[n - 1]) System.out.println System.out System System.out list[n - 1] list n - 1 n 1 {

				System.out.println(list[n - 2]);

			} System.out.println(list[n - 2]) System.out.println System.out System System.out list[n - 2] list n - 2 n 2 String[] args args public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	}
} public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	}
}
