#include <bits/stdc++.h>
using namespace std;
int max_except(vector<int>& seq, int& n, int& indent) {
  int max = 0;
  for (int a = 0; a < n; a++) {
    if (indent == a) continue;
    if (seq[a] > max) max = seq[a];
  }
  return max;
}
int main(void) {
  vector<int> seq;
  int buff, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> buff;
    seq.push_back(buff);
  }
  for (int i = 0; i < n; i++) {
    cout << max_except(seq, n, i) << '\n';
  }
  cout << endl;
  return 0;
}
