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