#include <bits/stdc++.h>
using namespace std;
int main(void) {
  unsigned int n;
  cin >> n;
  vector<unsigned int> vec(n);
  vector<unsigned int> vec2(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  for (unsigned int i = 0; i < n; i++) {
    vec2.clear();
    copy(vec.begin(), vec.end(), back_inserter(vec2));
    vec2.erase(vec2.begin() + i);
    unsigned int max = *std::max_element(vec2.begin(), vec2.end());
    cout << max << endl;
  }
  return 0;
}
