#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n = 0;
bool found[200005] = {};
int main() {
  cin >> n;
  int last = -1;
  int finding = n;
  int cur;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &cur);
    if (found[cur]) {
      printf("%d %d\n", last, finding);
      found[finding] = true;
      do {
        finding -= 1;
      } while (found[finding]);
    } else {
      if (last == -1) {
        printf("%d\n", cur);
      } else {
        printf("%d %d\n", last, cur);
      }
      if (finding == cur) {
        do {
          finding -= 1;
        } while (found[finding]);
      }
      found[cur] = true;
    }
    last = cur;
  }
  printf("%d %d\n", last, finding);
  return 0;
}
