#include <bits/stdc++.h>
int main() {
  int n, d[200007], human, h;
  int c[200007];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &d[i]);
  }
  for (int k = 0; k < n; k++) {
    c[k] = d[k];
  }
  int max = c[0];
  for (int i = 0; i < n; i++) {
    c[i] = 0;
    c[i - 1] = d[i - 1];
    for (int j = 0; j < n; j++) {
      if (max < c[j]) {
        max = c[j];
      }
    }
    printf("%d\n", max);
    max = 0;
  }
}
