#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  bool flag;
  int arr[N], B[N];
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    B[i] = arr[i];
  }
  if (N == 1) cout << arr[0] << endl;
  int n = sizeof(B) / sizeof(B[0]);
  sort(B, B + n);
  for (int i = 0; i < N; i++) {
    if (arr[i] < B[N - 1])
      cout << arr[i] << " " << B[N - 1] << endl;
    else if (arr[i] == B[N - 1]) {
      flag = false;
      for (int j = N - 2; j >= 0; j--) {
        if (arr[i] != B[j]) {
          flag = true;
          cout << arr[i] << " " << B[j] << endl;
          break;
        }
      }
      if (!flag) cout << arr[i] << " " << B[N - 1] << endl;
    }
  }
  return 0;
}
