#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
int n, a[maxn], deg[maxn], val[maxn], from[maxn], to[maxn];
priority_queue<pair<int, int> > q;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  char ch = nc();
  int sum = 0;
  while (!(ch >= '0' && ch <= '9')) ch = nc();
  while (ch >= '0' && ch <= '9') sum = sum * 10 + ch - 48, ch = nc();
  return sum;
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    a[i] = read();
    deg[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    val[i] = i;
    if (!deg[i]) q.push(make_pair(-val[i], i));
  }
  for (int i = n - 1; i >= 1; i--) {
    if (q.empty()) {
      printf("-1");
      return 0;
    }
    pair<int, int> pr = q.top();
    q.pop();
    int x = -pr.first;
    val[a[i]] = max(val[a[i]], x);
    deg[a[i]]--;
    from[i] = a[i];
    to[i] = pr.second;
    if (deg[a[i]] == 0) q.push(make_pair(-val[a[i]], a[i]));
  }
  if (q.size() > 1) {
    printf("-1");
    return 0;
  }
  printf("%d\n", q.top().second);
  for (int i = 1; i < n; i++) printf("%d %d\n", from[i], to[i]);
  return 0;
}
