#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (i == 1)
      cout << max(a[i + 1], a[i + 2]);
    else if (i == n)
      cout << max(a[i - 1], a[i - 2]);
    else
      cout << max(a[i - 1], a[i + 1]);
    cout << endl;
  }
  return 0;
}
