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