#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b;
  vector<int> a, c;
  for (int i = 0; i < n; i++) {
    cin >> b;
    a.push_back(b);
    c.push_back(b);
  }
  sort(a.begin(), a.end());
  for (int j = 0; j < n; j++) {
    (c[j] == a[n - 1]) ? cout << a[n - 2] : cout << a[n - 1];
    cout << "\n";
  }
  return 0;
}
