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