#include <bits/stdc++.h>
using namespace std;
int n, a[200005], d[200005];
priority_queue<int> q;
int read() {
  int x = 0, fl = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fl = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * fl;
}
int main() {
  n = read(), n--;
  for (int i = 1; i <= n; i++) a[i] = read(), d[a[i]]++;
  printf("%d\n", a[1]);
  for (int i = 1; i <= n + 1; i++)
    if (!d[i]) q.push(-i);
  for (int i = n; i >= 1; i--) {
    int x = -q.top();
    q.pop();
    printf("%d %d\n", x, a[i]);
    d[a[i]]--;
    if (!d[a[i]]) q.push(-a[i]);
  }
  return 0;
}
