#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long arr[N], A[N], ARR[N];
bool visited[N] = {};
int cnt[N] = {};
bool f;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n && cin >> arr[i]; ++i) {
    A[i] = arr[i];
  }
  sort(A, A + n);
  for (int i = 0; i < n; ++i) {
    if (arr[i] < A[n - 1])
      cout << A[n - 1] << endl;
    else
      cout << A[n - 2] << endl;
  }
  return 0;
}
