#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> v;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    v.push_back(A);
  }
  for (int i = 0; i < N; i++) {
    int max = 0;
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      if (max < v[j]) max = v[j];
    }
    cout << max << endl;
  }
}
