#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  vector<long long> B = A;
  sort(A.begin(), A.end());
  for (int i = 0; i < N; ++i) {
    if (A[i] != B[N - 1])
      cout << B[N - 1] << "\n";
    else
      cout << B[N - 2] << "\n";
  }
  return 0;
}
