#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;
int main() {
  int n;
  vector<pair<int, int> > a;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    a.push_back(make_pair(b, i));
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a.at(0).second != i) {
      cout << a.at(0).first << endl;
    } else {
      cout << a.at(1).first << endl;
    }
  }
}
