#include <bits/stdc++.h>
int main() {
  int count = 0, n;
  scanf("%d", &n);
  int str[200000];
  while (count != n) {
    scanf("%d", &str[count]);
    count++;
  }
  int max, i;
  count = 0;
  while (count != n) {
    i = 0;
    max = 0;
    while (i != n) {
      if (i != count) {
        if (max < str[i]) max = str[i];
      }
      i++;
    }
    count++;
    printf("%d\n", max);
  }
  return 0;
}
