#include <bits/stdc++.h>
const int maxn = 2e5;
int main() {
  int n;
  int a[maxn];
  int max = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    max = 0;
    for (int j = 1; j <= n; j++) {
      if (max < a[j] && j != i) max = a[j];
    }
    printf("%d\n", max);
  }
  return 0;
}
