#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int b[20000] = {0};
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  for (int j = 0; j < a; j++) {
    for (int k = 0; k < a; k++) {
      if (k = j) {
        continue;
      }
      int c;
      c = max(b[k], c);
      cout << c << endl;
    }
  }
}
