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