#include <bits/stdc++.h>
int main() {
  int a, b, c, d, k, i, j, l = 1;
  long long max = 0;
  int n[300005];
  int m[3000005];
  scanf("%d", &a);
  for (i = 1; i <= a; i++) scanf("%d", &n[i]);
  memset(m, 0, sizeof(m));
  for (k = 0; k < a; k++) {
    m[l] = 1;
    max = 0;
    for (j = 1; j <= a; j++) {
      if (m[j] == 0) {
        max = max > n[j] ? max : n[j];
      }
    }
    printf("%lld\n", max);
    m[l++] = 0;
  }
}
