#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, ele;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> ele;
    v.push_back(ele);
  }
  for (auto i = 0; i < n; i++) {
    ele = v[i];
    v.erase(v.begin() + i);
    cout << *max_element(v.begin(), v.end()) << "\n";
    v.insert(v.begin() + i, ele);
  }
}
