#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
constexpr long long INF9 = (long long)1e9 + 1;
constexpr long long INF18 = (long long)1e18 + 1;
constexpr long long MOD1 = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr long double PI = 3.141592653589793L;
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
int main() {
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int max_a = 0;
  vector<int> a(n), d(n);
  for (int i = 0; (i) < (n); ++(i)) {
    scanf("%d", &a[i]);
    d[i] = a[i];
  }
  sort((d).rbegin(), (d).rend());
  for (int i = 0; (i) < (n); ++(i)) {
    if (a[i] == d[0])
      printf("%d\n", d[1]);
    else
      printf("%d\n", d[0]);
  }
  return 0;
}
