#include <bits/stdc++.h>
using namespace std;
char _;
long long i, j, k, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s,
    t = 1, u, v, w, x, y, z, maxx = INT_MIN, minn = INT_MAX, ans = 0, sum = 0,
    cnt = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  long long A[n];
  for (long long i = 0; i < (n); i++) {
    cin >> A[i];
  }
  for (long long i = 0; i < (n); i++) {
    maxx = A[i];
    A[i] = 0;
    cout << *max_element(A, A + n) << endl;
    A[i] = maxx;
  }
  return 0;
}
