#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N];
  int max_num = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    max_num = max(max_num, A[i]);
    cout << "A[" << i << "] = " << A[i] << endl;
    cout << "MAX:" << max_num << endl;
  }
  for (int i = 0; i < N; i++) {
    if (A[i] != max_num) {
      cout << max_num << endl;
    } else {
      int ans = 0;
      for (int j = 0; j < N; j++) {
        if (i == j) continue;
        ans = max(ans, A[j]);
      }
      cout << ans << endl;
    }
  }
  return 0;
}
