#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
int main() {
  int n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b = a;
  sort(a.begin(), a.end(), greater<int>());
  if (b[0] == b[1]) {
    for (int i = 0; i < n; i++) cout << b[0] << endl;
  } else {
    for (int i = 0; i < n; i++) {
      if (a[i] == b[0])
        cout << b[1] << endl;
      else
        cout << b[0] << endl;
    }
  }
}
