#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 10;
int a[mx];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  a[0] = a[n];
  a[n + 1] = a[1];
  for (int i = 1; i <= n; i++) {
    printf("%d\n", max(a[i - 1], a[i + 1]));
  }
  return 0;
}
