#include <bits/stdc++.h>
using namespace std;
deque<int> cl() {
  size_t c;
  cin >> c;
  deque<int> l(c);
  for (size_t i = 0; i < c; ++i) cin >> l.at(i);
  return l;
}
int main() {
  auto l = cl();
  for (int i = 0; i < l.size(); ++i) {
    auto k = l;
    k.erase(k.begin() + i);
    cout << *max_element(k.begin(), k.end()) << endl;
  }
}
