#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
long long int mod = 1e9 + 7;
long long int n, a[200010], tmp[200010];
long long int;
int main() {
  cin >> n;
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    cin >> a[i];
    tmp[i] = a[i];
  }
  sort(tmp, tmp + n);
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    if (tmp[n - 1] != a[i])
      cout << tmp[n - 1] << endl;
    else
      cout << tmp[n - 2] << endl;
  }
  return 0;
}
