#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int INF = 999999999;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
  }
  vector<int> B = A;
  for (int i = 0; i < (N); i++) {
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    if (B[i] == A[0]) {
      cout << A[1] << endl;
    } else {
      cout << A[0] << endl;
    }
  }
  return 0;
}
