#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 < (n); ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i < (n); ++i) {
    int max = 1;
    for (long long j = 0; j < (n); ++j) {
      if (max < a[j] && i != j) max = a[j];
    }
    cout << max << endl;
  }
}
