#include <bits/stdc++.h>
using namespace std;
void ma_x(int i, int a[], int n) {
  int maaa = INT_MIN;
  for (int j = 0; j < n; j++) {
    if (j != i) {
      if (maaa < a[j]) {
        maaa = a[j];
      }
    }
  }
  cout << maaa << endl;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    ma_x(i, a, n);
  }
  return 0;
}
