#include <bits/stdc++.h>
using namespace std;
vector<long long> v, vc;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long a = 0, b = 0, c, d, e, f = 0, l, g, m, n, k, i, j, t, p, q;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
    vc.push_back(a);
  }
  sort(v.begin(), v.end());
  for (i = 0; i < n - 1; i++) {
    if (vc[i] < v[n - 1])
      cout << v[n - 1] << '\n';
    else
      cout << v[n - 2] << '\n';
  }
  return 0;
}
