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