#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, i = 0, s = 0, max = 0;
  cin >> N;
  vector<int> A(N);
  while (i < N) {
    cin >> A.at(i);
    i++;
  }
  i = 0;
  while (i < N) {
    s = 0;
    while (s < N) {
      if (s != i && A.at(s) > max) {
        max = A.at(s);
      }
      s++;
    }
    cout << max << endl;
    i++;
  }
}
