#include <bits/stdc++.h>
using namespace std;
int N, A[200010], B[200010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> N;
  memset(B, 0, sizeof(B));
  for (int i = 0; i < N; i++) cin >> A[i];
  memcpy(B, A, N);
  sort(A, A + N);
  reverse(A, A + N);
  for (int i = 0; i < N; i++) {
    if (B[i] == A[0])
      cout << A[1];
    else
      cout << A[0];
    puts("");
  }
  return 0;
}
