#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  vector<int> ys = xs;
  sort(ys.begin(), ys.end());
  for (int i = 0; i < n; i++) {
    if (xs[i] == ys[n - 1])
      cout << ys[n - 2] << endl;
    else
      cout << ys[n - 1] << endl;
  }
}
