#include <bits/stdc++.h>
using namespace std;
int mayor(const vector<int>& v, int l) {
  int m = v[0];
  for (size_t i = 0; i < v.size(); i++) {
    if (i != l) {
      if (m <= v[i]) m = v[i];
    }
  }
  return m;
}
int main() {
  int n, j, l = 0;
  vector<int> v;
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    cin >> j;
    v.push_back(j);
  }
  for (size_t j = 0; j < v.size(); j++) {
    cout << mayor(v, l) << endl;
    l++;
  }
  return 0;
}
