#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
using P = pair<long long, long long>;
using PP = pair<P, long long>;
const long long mod = 1e9 + 7, inf = 1e16;
long long modpow(long long x, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      if (mod <= ans * x)
        ans = ans * x % mod;
      else
        ans *= x;
    }
    if (mod <= x * x)
      x = x * x % mod;
    else
      x *= x;
    n >>= 1;
  }
  return ans;
}
long long fact_memo[114514];
long long fact(long long n) {
  long long ans = 1;
  if (fact_memo[n]) return fact_memo[n];
  for (long long i = 0; i < (long long)(n); i++) {
    ans *= (i + 1);
    if (mod <= ans) ans %= mod;
    fact_memo[i + 1] = ans;
  }
  return (ans + mod) % mod;
}
long long comb(long long n, long long r) {
  if (n < r) return 0;
  if (n - r < r) r = n - r;
  return (fact(n) * modpow(fact(n - r), mod - 2) % mod *
              modpow(fact(r), mod - 2) +
          mod) %
         mod;
}
long long perm(long long n, long long r) {
  if (n < r) return 0;
  if (n - r < r) r = n - r;
  return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
bool pri(long long p) {
  for (long long i = 2; i * i <= p; i++)
    if (p % i == 0) return false;
  return p > 1;
}
long long n;
long long a[100010];
long long l[100010], r[100010];
signed main() {
  cin >> n;
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < (long long)(n); i++) {
    if (i == 0) continue;
    l[i] = max(a[i - 1], l[i - 1]);
  }
  for (long long i = (long long)(n); i >= 0; i--) {
    if (i == n - 1) continue;
    r[i] = max(a[i + 1], r[i + 1]);
  }
  for (long long i = 0; i < (long long)(n); i++) {
    cout << max(l[i], r[i]) << endl;
  }
}
