#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), ans(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long x = 0; x < n; x++) {
    int latest = 0;
    for (long long y = 0; y < n; y++) {
      if (x == y) continue;
      if (a[y] > latest) {
        latest = a[y];
      }
    }
    ans[x] = latest;
  }
  for (long long answer : ans) {
    cout << answer << endl;
  }
  return 0;
}
