#include <bits/stdc++.h>
using namespace std;
int a[200000 + 7];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
      int maxx = -66666;
      for (int j = 1; j <= n; j++) {
        if (i == j)
          continue;
        else {
          if (a[j] >= maxx) {
            maxx = a[j];
          }
        }
      }
      cout << maxx << endl;
    }
  }
  return 0;
}
