#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, t, j, max = 0;
  int a[200020] = {};
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++) {
      t = a[i];
      a[i] = 0;
      for (j = 0; j < n; j++) {
        max = max > a[j] ? max : a[j];
      }
      printf("%d\n", max);
      a[i] = t;
      max = 0;
    }
    memset(a, 0, sizeof(a));
  }
}
