#include <bits/stdc++.h>
unsigned gcd(unsigned a, unsigned b) {
  if (a < b) return gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
using namespace std;
template <class T = long long>
T input() {
  T x;
  cin >> x;
  return x;
}
template <class T>
void output(T x) {
  cout << x << endl;
}
int main() {
  int N = input();
  vector<int> A;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    A[i] = input();
  }
  for (int i = 0; i < N; i++) {
    int mx = 0;
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      mx = max(mx, A[j]);
    }
    output(mx);
  }
  return 0;
}
