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