#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {
  ll sum = 0;
  for (long long int i = 0; i < x.size(); i++) sum += x[i];
  return sum;
}
void vdeb(string s, vll x) {
  cout << s << " = { ";
  for (long long int i = 0; i < x.size(); i++) cout << x[i] << ' ';
  cout << '}' << endl;
}
int main() {
  ll n;
  cin >> n;
  vll a(n);
  vll b(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (long long int i = 0; i < n; i++) {
    ll x = b[i];
    sort((a).rbegin(), (a).rend());
    ;
    if (a[0] == x)
      cout << a[1] << endl;
    else
      cout << a[0] << endl;
  }
  return 0;
}
