#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int i, j, k, l, m;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int max;
  for (j = 0; j < n; j++) {
    max = a[0];
    if (j == 0) {
      max = a[1];
      for (k = 2; k < n; k++) {
        if (max < a[k]) {
          max = a[k];
        } else {
          max = max;
        }
      }
      printf("%d\n", max);
    } else {
      for (l = 0; l < j; l++) {
        if (max < a[l]) {
          max = a[l];
        } else {
          max = max;
        }
      }
      for (m = j + 1; m < n; m++) {
        if (max < a[m]) {
          max = a[m];
        } else {
          max = max;
        }
      }
      printf("%d\n", max);
    }
  }
  return 0;
}
