#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  int a[n];
  int max = INT_MIN;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > max) {
      max = a[i];
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] < max) {
      cout << max << endl;
    } else {
      int m = INT_MIN;
      for (int j = 0; j < n; j++) {
        if (j != i) {
          if (a[j] > m) {
            m = a[j];
          }
        }
      }
      cout << m << endl;
    }
  }
}
