#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> vec_a(n);
  for (size_t i = 0; i < n; i++) {
    std::cin >> vec_a.at(i);
  }
  std::vector<int> vec_zero(vec_a.begin() + 1, vec_a.end());
  sort(vec_zero.begin(), vec_zero.end());
  std::cout << vec_zero.at(vec_zero.size() - 1) << std::endl;
  for (size_t i = 1; i < n; i++) {
    std::vector<int> vec(vec_a.begin(), vec_a.begin() + i);
    std::vector<int> vec_temp(vec_a.begin() + i + 1, vec_a.end());
    std::copy(vec_temp.begin(), vec_temp.end(), std::back_inserter(vec));
    sort(vec.begin(), vec.end());
    std::cout << vec.at(vec.size() - 1) << std::endl;
  }
  return 0;
}
