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