#include <bits/stdc++.h>
const long long INF = 1e18L + 5;
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  vector<long long> ans(n);
  for (long long i = 0; i < n; i++) {
    long long mx = 0;
    for (long long j = 0; j < n; j++) {
      if (i == j)
        continue;
      else
        mx = max(mx, a[j]);
    }
    ans[i] = mx;
  }
  for (long long i = 0; i < (long long)(n); i++) cout << ans[i] << "\n";
  return 0;
}
