#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int maxA = *max_element(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    if (maxA == A.at(i)) {
      vector<int> B = A;
      sort(B.begin(), B.end(), greater<int>());
      B.erase(B.begin());
      cout << B.at(0) << endl;
    } else {
      cout << maxA << endl;
    }
  }
  return 0;
}
