#include <bits/stdc++.h>
using namespace std;
int gi() {
  int a;
  scanf("%d", &a);
  return a;
}
long long gli() {
  long long a;
  scanf("%I64d", &a);
  return a;
}
int a[200000];
int v[200000];
pair<int, int> e[200000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = gi();
  for (int i = 0; i < n - 1; i++) a[i] = gi() - 1;
  memset(v, 0, sizeof(v));
  v[a[0]] = 1;
  int f = n - 1;
  int en = 0;
  int i = 0;
  while (i < n - 1) {
    int j = i;
    while (f >= 0 && v[f] == 1) f--;
    if (f == -1) {
      printf("-1\n");
      return 0;
    }
    v[f] = 1;
    while (j + 1 < n - 1 && v[a[j + 1]] == 0) {
      j++;
      v[a[j]] = 1;
    }
    int jj = j + 1;
    int bb = f;
    while (j >= i) {
      e[en++] = {a[j], bb};
      bb = a[j--];
    }
    i = jj;
  }
  printf("%d\n", a[0] + 1);
  for (int i = 0; i < n - 1; i++)
    printf("%d %d\n", e[i].first + 1, e[i].second + 1);
  return 0;
}
