#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int k = n;
  while (k--) {
    int max = 0;
    for (int i = 0; i < (n - k); i++) {
      if (arr[i] > max) max = arr[i];
    }
    for (int i = n - k + 1; i < n; i++) {
      if (arr[i] > max) max = arr[i];
    }
    cout << max << endl;
  }
  return 0;
}
