#include <bits/stdc++.h>
template <typename T>
void remove(std::vector<T> &vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
int main() {
  int N, a;
  std::vector<int> A;
  std::vector<int> A_tmp;
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> a;
    A.push_back(a);
  }
  for (int j = 0; j < N; ++j) {
    A_tmp = A;
    remove(A_tmp, j);
    std::cout << *std::max_element(A_tmp.begin(), A_tmp.end()) << '\n';
  }
}
