import java.util.*;

public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] L = new int[N];
		int[] R = new int[N];
		for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		}
		for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		}
		StringBuilder buff = new StringBuilder();
		for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		}
		System.out.print(buff);
	}
} import java.util.*; util.* java public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] L = new int[N];
		int[] R = new int[N];
		for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		}
		for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		}
		StringBuilder buff = new StringBuilder();
		for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		}
		System.out.print(buff);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] L = new int[N];
		int[] R = new int[N];
		for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		}
		for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		}
		StringBuilder buff = new StringBuilder();
		for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		}
		System.out.print(buff);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] L = new int[N];
		int[] R = new int[N];
		for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		}
		for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		}
		StringBuilder buff = new StringBuilder();
		for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		}
		System.out.print(buff);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N]; A new int[N] N for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			A[i] = sc.nextInt();
		} {
			A[i] = sc.nextInt();
		} A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc int[] L = new int[N]; L new int[N] N int[] R = new int[N]; R new int[N] N for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			L[i] = Math.max(L[i-1], A[i-1]);
		} {
			L[i] = Math.max(L[i-1], A[i-1]);
		} L[i] = Math.max(L[i-1], A[i-1]) L[i] L i Math.max(L[i-1], A[i-1]) Math.max Math L[i-1] L i-1 i 1 A[i-1] A i-1 i 1 for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		} int i = N-2; int i = N-2; i N-2 N 2 i >= 0 i 0 i-- i-- i {
			R[i] = Math.max(R[i+1], A[i+1]);
		} {
			R[i] = Math.max(R[i+1], A[i+1]);
		} R[i] = Math.max(R[i+1], A[i+1]) R[i] R i Math.max(R[i+1], A[i+1]) Math.max Math R[i+1] R i+1 i 1 A[i+1] A i+1 i 1 StringBuilder buff = new StringBuilder(); buff new StringBuilder() for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		} {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		} buff.append(Math.max(L[i], R[i])) buff.append buff Math.max(L[i], R[i]) Math.max Math L[i] L i R[i] R i buff.append('\n') buff.append buff '\n' System.out.print(buff) System.out.print System.out System System.out buff String[] args args public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] L = new int[N];
		int[] R = new int[N];
		for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		}
		for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		}
		StringBuilder buff = new StringBuilder();
		for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		}
		System.out.print(buff);
	}
} public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] L = new int[N];
		int[] R = new int[N];
		for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		}
		for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		}
		StringBuilder buff = new StringBuilder();
		for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		}
		System.out.print(buff);
	}
} Main
import java.util.*;

public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] L = new int[N];
		int[] R = new int[N];
		for (int i = 1; i < N; i++) {
			L[i] = Math.max(L[i-1], A[i-1]);
		}
		for (int i = N-2; i >= 0; i--) {
			R[i] = Math.max(R[i+1], A[i+1]);
		}
		StringBuilder buff = new StringBuilder();
		for (int i = 0; i < N; i++) {
			buff.append(Math.max(L[i], R[i]));
			buff.append('\n');
		}
		System.out.print(buff);
	}
}
