#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int max1 = *max_element(a, a + n);
  int max2 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < max1)
      printf("%d\n", max1);
    else {
      for (int j = 0; j < n; j++)
        if (j != i) max2 = max(max2, a[j]);
      printf("%d\n", max2);
    }
  }
}
