#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18 + 1;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long idx = 0;
  long N;
  cin >> N;
  vector<long> A(N, 0);
  long a;
  for (size_t i = 0; i < N; i++) {
    cin >> a;
    for (size_t j = 0; j < N; j++) {
      if (i != j) A[j] = max(A[j], a);
    }
  }
  for (size_t i = 0; i < N; i++) {
    cout << A[i] << endl;
  }
  return 0;
}
