#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a, int64_t b) { return b != 0 ? gcd(b, a % b) : a; }
int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); }
int ctoi(char c) { return c - '0'; }
int main() {
  int64_t n;
  cin >> n;
  vector<int> vec(n);
  int mx = INT_MIN;
  for (int i = 0; i < (n); i++) {
    cin >> vec.at(i);
    mx = max(mx, vec.at(i));
  }
  for (int i = 0; i < (n); i++) {
    if (vec.at(i) != mx) {
      cout << mx << endl;
    } else {
      int mx2 = INT_MIN;
      for (int j = 0; j < (n); j++) {
        if (i != j) {
          mx2 = max(mx2, vec.at(j));
        }
      }
      cout << mx2 << endl;
    }
  }
  return 0;
}
