#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c;
  int x = 0;
  int b = 1;
  do {
    c = getchar();
    if (c == 45) b = -1;
  } while (c > 57 || c < 48);
  do x = x * 10 + c - 48, c = getchar();
  while (c <= 57 && c >= 48);
  x *= b;
  return x;
}
priority_queue<int, vector<int>, greater<int> > pq;
const int maxn = 2e5 + 5;
int n, rd[maxn], a[maxn];
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    a[i] = read();
    rd[a[i]]++;
  }
  printf("%d\n", a[1]);
  for (int i = 1; i <= n; i++)
    if (!rd[i]) pq.push(i);
  for (int i = n - 1; i >= 1; i--) {
    int x = pq.top();
    pq.pop();
    rd[a[i]]--;
    printf("%d %d\n", a[i], x);
    if (!rd[a[i]]) pq.push(a[i]);
  }
  return 0;
}
