#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n;
  vector<long int> v;
  scanf("%ld", &n);
  long int a[n], i;
  for (i = 0; i < n; ++i) {
    scanf("%ld", &a[i]);
    v.push_back(a[i]);
  }
  auto it = v.begin();
  for (i = 0; i < n; ++i) {
    auto it = v.begin();
    v.erase(it);
    printf("%ld\n", *max_element(v.begin(), v.end()));
    v.push_back(a[i]);
    ++it;
  }
}
