#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long A, B, i, j;
  cin >> A;
  unsigned long long answer[A];
  for (i = 0; i < A; i++) cin >> answer[i];
  for (i = 0; i < A; i++) {
    int minimum = 0;
    for (j = 0; j < A; j++) {
      if (j == i) {
        continue;
      } else {
        if (answer[j] > minimum) minimum = answer[j];
      }
    }
    cout << minimum << endl;
  }
}
