#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int buff;
  int max = *max_element(A.begin(), A.end());
  vector<int>::iterator maxIt = max_element(A.begin(), A.end());
  size_t maxIndex = distance(A.begin(), maxIt);
  A[maxIndex] = 1;
  int max2 = *max_element(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    if (i != maxIndex) {
      cout << max2 << endl;
    } else {
      cout << max << endl;
    }
  }
  return 0;
}
