#include <bits/stdc++.h>
using namespace std;
int helper(vector<int>& v, int n) {
  int m = -1;
  for (int i = 0; i < v.size(); i++) {
    if (i == n) continue;
    m = max(m, v[i]);
  }
  return m;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i] = helper(a, i);
    cout << ans[i] << "\n";
  }
  return 0;
}
