#include <bits/stdc++.h>
int main() {
  int n, i, j, k;
  long max;
  long *a;
  scanf("%d", &n);
  a = (long *)malloc(n * sizeof(long));
  for (i = 0; i < n; ++i) scanf("%ld", &a[i]);
  for (i = 0; i < n; ++i) {
    if (i > n) continue;
    if (k == i || i == 0) {
      max = 0;
      for (j = 0; j < n; ++j) {
        if (i == j) {
          continue;
        }
        if (max < a[j]) {
          max = a[j];
          k = j;
        }
      }
    }
    printf("%ld\n", max);
  }
  return 0;
}
