#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a[212345], b[112345];
  cin >> n;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = (0); i < (n); i++) {
    if (a[i] == b[n - 1])
      cout << b[n - 2] << endl;
    else
      cout << b[n - 1] << endl;
  }
  return 0;
}
