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