#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int parent[n];
  for (int i = 0; i < n - 1; i++) {
    cin >> arr[i];
    arr[i] -= 1;
    parent[i] = -1;
  }
  parent[n - 1] = -1;
  parent[arr[0]] = -2;
  int max_cur = n - 1;
  for (int i = 0; i < n - 1; i++) {
    if (i != n - 2 && parent[arr[i + 1]] == -1) {
      parent[arr[i + 1]] = arr[i];
    } else {
      while (parent[max_cur] != -1) {
        max_cur -= 1;
      }
      parent[max_cur] = arr[i];
    }
  }
  cout << arr[0] + 1 << endl;
  for (int i = 0; i < n; i++) {
    if (i != arr[0]) {
      cout << (i + 1) << " " << parent[i] + 1 << endl;
    }
  }
}
