#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T&... t) {
  ((cin >> t), ...);
}
template <typename... T>
void write(T... t) {
  ((cout << t), ...);
}
using LL = long long;
using pii = pair<int, int>;
const int INF = 2e9;
const int MAXN = 2e5 + 3;
int n;
int arr[MAXN];
int brr[MAXN];
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read(n);
  for (int i = 1; i <= n; ++i) read(arr[i]);
  for (int i = 1; i <= n; ++i) brr[i] = arr[i];
  sort(brr + 1, brr + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (arr[i] != brr[n])
      write(brr[n], '\n');
    else
      write(brr[n - 1], '\n');
  }
}
