#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  int t = 0, f = 0;
  ;
  for (int i = 0; i < (n); ++i) {
    t = a[i];
    a[i] = 0;
    ans[i] = *max_element(a.begin(), a.end());
    a[i] = t;
  }
  for (int i = 0; i < (n); ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
