#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, save;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  for (int i = 0; i < vec.size(); i++) {
    save = vec[i];
    vec[i] = 0;
    cout << *max_element(vec.begin(), vec.end()) << endl;
    vec[i] = save;
  }
  return 0;
}
