#include <bits/stdc++.h>
int main(void) {
  int N, *A, *pA, i, j, max;
  scanf("%d", &N);
  A = (int *)calloc(N, sizeof(int));
  if (A == NULL) exit(1);
  pA = A;
  for (j = 1; j <= N; j++) {
    scanf("%d", pA);
    pA++;
  }
  for (i = 1; i <= N; i++) {
    pA = A;
    max = i == 1 ? *(pA + 1) : *pA;
    for (j = 1; j < i; j++) {
      if (*pA > max) max = *pA;
      pA++;
    }
    pA++;
    for (j = i + 1; j <= N; j++) {
      if (*pA > max) max = *pA;
      pA++;
    }
    printf("%d\n", max);
  }
  free(A);
  return 0;
}
