#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n, 0), b(n, 0);
  for (ll i = 0; i < (n); i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end(), greater<ll>());
  for (ll i = 0; i < (n); i++) {
    if (a[i] == b[0])
      cout << b[i] << endl;
    else
      cout << b[0] << endl;
  }
}
