#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
  int N, tmp, max = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < N; i++) {
    tmp = a[i];
    a[i] = 0;
    max = 0;
    for (int j = 0; j < N; j++)
      if (max < a[j]) max = a[j];
    printf("%d\n", max);
    a[i] = tmp;
  }
  return 0;
}
