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