#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
int main() {
  long long int a, b[200010], c[200010];
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b[i];
    c[i] = b[i];
  }
  sort(b, b + a, greater<int>());
  for (int i = 0; i < a; i++) {
    if (c[i] = b[0]) {
      cout << b[1] << endl;
    } else {
      cout << b[0] << endl;
    }
  }
}
