#include <bits/stdc++.h>
int main() {
  int n;
  int A[20000];
  int max1 = 0;
  int max2 = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    if (A[i] > A[max1])
      max1 = i;
    else if (A[i] > A[max2])
      max2 = i;
  }
  for (int i = 0; i < n; i++) {
    if (i == max1)
      printf("%d\n", A[max2]);
    else
      printf("%d\n", A[max1]);
  }
}
