#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<int> ans(n);
  vector<int>::iterator iter = max_element(a.begin(), a.end());
  size_t index = distance(a.begin(), iter);
  for (int i = 0; i < (int)(n); i++) {
    if (i == index)
      ans[i] = *max_element(a.begin(), a.end());
    else
      ans[i] = a[index];
  }
  for (int i = 0; i < (int)(n); i++) cout << ans[i] << endl;
}
