#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    int a_i = A[i];
    vector<int> temp = A;
    temp[i] = 0;
    sort(temp.begin(), temp.end(), greater<int>());
    cout << temp[0] << endl;
  }
  return 0;
}
