#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, max, cnt = 0;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  while (cnt < N) {
    max = 0;
    for (int i = 0; i < N; i++) {
      if (cnt == i) continue;
      if (A[i] > max) max = A[i];
    }
    cout << max << endl;
    cnt++;
  }
  return 0;
}
