#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) cin >> vec.at(i);
  for (auto it = vec.begin(); it != vec.end(); it++) {
    long long elem = *it;
    vec.erase(it);
    cout << *max_element(vec.begin(), vec.end()) << endl;
    vec.insert(it, elem);
  }
  return 0;
}
