#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long INF = 1e18;
const long long M = 1e9 + 7;
const long long maxn = 3e5;
long long a[maxn], b[maxn];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (long long i = 0; i < n; ++i) {
    if (a[i] == b[n - 1]) {
      cout << b[n - 2] << endl;
    } else {
      cout << b[n - 1] << endl;
    }
  }
  return 0;
}
