#include <bits/stdc++.h>
using namespace std;
int main() {
  ifstream in("data1.txt");
  cin.rdbuf(in.rdbuf());
  int N;
  cin >> N;
  vector<int> v(N);
  priority_queue<int> q;
  for (int i = 0; i < (int)(N); i++) {
    cin >> v[i];
    q.push(v[i]);
  }
  int max = q.top();
  for (int i = 0; i < N; i++) {
    if (v[i] != max) {
      printf("%d\n", max);
    } else {
      printf("%d\n", v[i]);
    }
  }
}
