#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[200000];
  int a[200000];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    a[i] = A[i];
  }
  int tmp = 0;
  int ans[200000];
  for (int i = 0; i < N; i++) {
    a[i] = 0;
    for (int j = 0; j < N; j++) {
      tmp = max(tmp, a[j]);
    }
    ans[i] = tmp;
    a[i] = A[i];
    tmp = 0;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
