import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

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];
    List<Integer> list = new ArrayList<>();
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    }
    
    Collections.sort(list);
    
    for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(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 import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections 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];
    List<Integer> list = new ArrayList<>();
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    }
    
    Collections.sort(list);
    
    for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(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];
    List<Integer> list = new ArrayList<>();
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    }
    
    Collections.sort(list);
    
    for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2));
    }
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    List<Integer> list = new ArrayList<>();
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    }
    
    Collections.sort(list);
    
    for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(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 List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    } {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    } a[i] = Integer.parseInt(in.readLine()) a[i] a i Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in list.add(a[i]) list.add list a[i] a i Collections.sort(list) Collections.sort Collections list for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2));
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2));
    } {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2));
    } System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2)) System.out.println System.out System System.out list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2) list.get(n-1)!=a[i] list.get(n-1) list.get list n-1 n 1 a[i] a i list.get(n-1) list.get list n-1 n 1 list.get(n-2) list.get list 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];
    List<Integer> list = new ArrayList<>();
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    }
    
    Collections.sort(list);
    
    for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(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];
    List<Integer> list = new ArrayList<>();
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    }
    
    Collections.sort(list);
    
    for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2));
    }
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

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];
    List<Integer> list = new ArrayList<>();
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      list.add(a[i]);
    }
    
    Collections.sort(list);
    
    for(int i=0; i<n; i++) {
      System.out.println(list.get(n-1)!=a[i]?list.get(n-1):list.get(n-2));
    }
  }
}