#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    cin >> v[i];
  }
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int tmp = v[i];
    v[i] = *min_element((v).begin(), (v).end());
    cout << *max_element((v).begin(), (v).end()) << endl;
    v[i] = tmp;
  }
  return 0;
}
