#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  ll max;
  vll x(n);
  for (ll i = 0; i < n; i++) x[i] = a[i];
  for (ll i = 0; i < n; i++) {
    a.erase(a.begin() + i);
    max = *max_element(a.begin(), a.end());
    cout << max << endl;
    a.push_back(1);
    for (ll j = 0; j < n; j++) a[j] = x[j];
  }
  return 0;
}
