#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  vector<int> A_arr;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    A_arr.push_back(tmp);
  }
  for (int i = 0; i < N; ++i) {
    int max = 0;
    for (int j = 0; j < N; ++j) {
      if (i == j)
        continue;
      else {
        if (max < A_arr[j]) max = A_arr[j];
      }
    }
    cout << max << endl;
  }
  return 0;
}
