#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int(i) = 0; (i) < (N); (i)++) cin >> A[i];
  int M;
  for (int(j) = 0; (j) < (N); (j)++) {
    M = 0;
    for (int(k) = 0; (k) < (N); (k)++) {
      if (j == k) continue;
      if (M < max(M, A[k])) M = max(M, A[k]);
    }
    cout << M << endl;
  }
  return 0;
}
