#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<int> a(200000);
  vector<int> ans(200000);
  cin >> N;
  for (int i = 1; i < N + 1; i++) {
    cin >> a.at(i);
  }
  int b;
  for (int i = 1; i < N + 1; i++) {
    b = a[i];
    a[i] = 0;
    ans[i] = *std::max_element(a.begin(), a.end());
    a[i] = b;
  }
  for (int i = 1; i < N + 1; i++) {
    cout << ans.at(i) << endl;
  }
}
