#include <bits/stdc++.h>
int main(void) {
  int N;
  int A[200000];
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  for (int j = 1; j <= N; j++) {
    int max = 0;
    int k = 1;
    while (k < j) {
      if (A[k] >= max) {
        max = A[k];
      }
      k++;
    }
    k++;
    while (k <= N) {
      if (A[k] >= max) {
        max = A[k];
      }
      k++;
    }
    printf("%d\n", max);
  }
  return 0;
}
