#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int A[200100];
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) {
    int maxVal = 0;
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      if (maxVal < A[j]) {
        maxVal = A[j];
      }
    }
    cout << maxVal << endl;
  }
  return 0;
}
