import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  } main {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] b = new int[n]; b new int[n] n int[] c = new int[n]; c new int[n] n for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    } {
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    } int t = scan.nextInt(); t scan.nextInt() scan.nextInt scan b[i] = t b[i] b i t c[i] = t c[i] c i t Arrays.sort(c) Arrays.sort Arrays c if (n == 1){
      System.out.println(c[0]);
      return;
    } n == 1 n 1 {
      System.out.println(c[0]);
      return;
    } System.out.println(c[0]) System.out.println System.out System System.out c[0] c 0 return; for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    } int j=0; int j=0; j 0 j<n j n j++ j++ j {
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    } {
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    } if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      } b[j] != c[n-1] b[j] b j c[n-1] c n-1 n 1 {
        System.out.println(c[n-1]);
      } System.out.println(c[n-1]) System.out.println System.out System System.out c[n-1] c n-1 n 1 {
        System.out.println(c[n-2]);
      } System.out.println(c[n-2]) System.out.println System.out System System.out c[n-2] c n-2 n 2 String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  }
}
