#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long a[20005] = {}, esc[20005] = {}, ans[20005] = {};
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      esc[j] = a[j];
    }
    esc[i] = 0;
    sort(esc, esc + n, greater<int>());
    ans[i] = esc[0];
  }
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
