#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> ary(N);
  for (long i = 0; i < N; i++) cin >> ary[i];
  vector<int> ans(N);
  for (long i = 0; i < N; i++) {
    int maxx = 0;
    for (long j = 0; j < N; j++) {
      if (i != j) {
        maxx = max(ary[j], maxx);
      }
    }
    ans[i] = maxx;
  }
  for (long i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}
