#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int max, c;
  max = 0;
  c = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    c = A.at(i);
    A.at(i) = 0;
    max = *max_element(A.begin(), A.end());
    cout << max << endl;
    A.at(i) = c;
  }
}
