import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int[] a_sort = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    }
    
    Arrays.sort(a_sort);
    
    for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    }
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io import java.util.Arrays; Arrays java.util public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int[] a_sort = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    }
    
    Arrays.sort(a_sort);
    
    for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    }
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int[] a_sort = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    }
    
    Arrays.sort(a_sort);
    
    for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    }
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int[] a_sort = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    }
    
    Arrays.sort(a_sort);
    
    for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    }
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(in.readLine()); n Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in int[] a = new int[n]; a new int[n] n int[] a_sort = new int[n]; a_sort new int[n] n for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    } {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    } a[i] = Integer.parseInt(in.readLine()) a[i] a i Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in a_sort[i] = a[i] a_sort[i] a_sort i a[i] a i Arrays.sort(a_sort) Arrays.sort Arrays a_sort for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    } {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    } System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]) System.out.println System.out System System.out a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2] a_sort[n-1]!=a[i] a_sort[n-1] a_sort n-1 n 1 a[i] a i a_sort[n-1] a_sort n-1 n 1 a_sort[n-2] a_sort n-2 n 2 String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int[] a_sort = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    }
    
    Arrays.sort(a_sort);
    
    for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    }
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int[] a_sort = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    }
    
    Arrays.sort(a_sort);
    
    for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    }
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int[] a_sort = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      a_sort[i] = a[i];
    }
    
    Arrays.sort(a_sort);
    
    for(int i=0; i<n; i++) {
      System.out.println(a_sort[n-1]!=a[i]?a_sort[n-1]:a_sort[n-2]);
    }
  }
}