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