import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      int youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    }
} 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 youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    }
} Main public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      int youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    } main {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      int youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int youso1[] = new int[N]; youso1 new int[N] N for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        	youso1[i] = sc.nextInt();
      } {
        	youso1[i] = sc.nextInt();
      } youso1[i] = sc.nextInt() youso1[i] youso1 i sc.nextInt() sc.nextInt sc int[] youso2 = youso1.clone(); youso2 youso1.clone() youso1.clone youso1 Arrays.sort(youso2) Arrays.sort Arrays youso2 for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      } {
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      } if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            } youso1[i] < youso2[N-1] youso1[i] youso1 i youso2[N-1] youso2 N-1 N 1 {
              	System.out.println(youso2[N-1]);
            } System.out.println(youso2[N-1]) System.out.println System.out System System.out youso2[N-1] youso2 N-1 N 1 {
              	System.out.println(youso2[N-2]);
            } System.out.println(youso2[N-2]) System.out.println System.out System System.out youso2[N-2] youso2 N-2 N 2 String[] args args public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      int youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    }
} public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      int youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      int youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    }
}