#include <bits/stdc++.h>
using namespace std;
vector<int> twoadd(vector<int> v, int N) {
  v[N - 1] += 1;
  int ind = N - 1;
  int j = N - 1;
  for (j = N - 1; j >= 1; j--) {
    if (v[j] > 1) {
      v[j - 1] += 1;
      v[j] = 0;
    }
  }
  return v;
}
long long fibonatti(long long d) {
  long long count = 0;
  long long f1 = 1;
  long long f2 = 1;
  long long temp;
  if (d == 1) {
    count = f1;
  } else if (d == 2) {
    count = f2;
  } else if (d == 0) {
    count = 1;
  } else {
    for (int i = 0; i < d - 2; i++) {
      temp = f1 + f2;
      f1 = f2;
      f2 = temp;
    }
    count = temp;
  }
  return count;
}
unsigned long long GCD(long long L, long long R) {
  if (L > R) {
    long long temp = R;
    R = L;
    L = temp;
  }
  unsigned long long pp = 0, ppt = 0;
  unsigned long long ans = 0;
  if (R % L == 0) {
    ans = L;
  } else {
    while (true) {
      ppt = pp;
      pp = R % L;
      if (pp == 0) {
        ans = ppt;
        break;
      }
      R = L;
      L = pp;
    }
  }
  return ans;
}
unsigned long long LCM(long long L, long long R) {
  unsigned long long ans;
  unsigned long long gcd = GCD(L, R);
  ans = (L / gcd) * R;
  return ans;
}
vector<long long> fc(3000 + 1);
vector<long long> ifc(3000 + 1);
long long modpow(long long x, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * x % 1000000007;
    }
    x = x * x % 1000000007;
    n >>= 1;
  }
  return ans;
}
void Conb() {
  fc[0] = 1;
  ifc[0] = 1;
  for (long long i = 0; i < 3000; i++) {
    fc[i + 1] = fc[i] * (i + 1) % 1000000007;
    ifc[i + 1] = ifc[i] * modpow(i + 1, 1000000007 - 2) % 1000000007;
  }
}
unsigned long long Combination(long long L, long long R) {
  unsigned long long up = 1, ans;
  Conb();
  if (L == 0 && R == 0) {
    return 1;
  } else if (L < R || L < 0) {
    return 0;
  } else {
    long long t = ifc[L - R] * ifc[R] % 1000000007;
    ans = t * fc[L] % 1000000007;
  }
  return ans;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int maxx = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (maxx < A[i]) {
      maxx = A[i];
    }
  }
  for (int i = 0; i < N; i++) {
    int max = 0;
    for (int j = 0; j < N; j++) {
      if (i != j) {
        if (max < A[j]) {
          max = A[j];
        }
      }
      if (max == maxx) {
        break;
      }
    }
    cout << max << endl;
  }
}
