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