#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;
int res(int A[], int N, int a) {
  int ans = 0;
  for (int i = 0; i < (int)(N); i++) {
    if (i == a) continue;
    ans = max(ans, A[i]);
  }
  return ans;
}
int main() {
  int N, A[MAX];
  cin >> N;
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  for (int a = 0; a < (int)(N); a++) {
    cout << res(A, N, a) << endl;
  }
}
