#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int deg[maxn];
int a[maxn];
int n;
priority_queue<int, vector<int>, greater<int> > q;
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) deg[i] = 1;
  for (int i = 0; i < n - 1; i++) scanf("%d", &a[i]), deg[a[i]]++;
  for (int i = 1; i <= n; ++i) {
    if (deg[i] == 1) q.push(i);
  }
  printf("%d\n", a[0]);
  int cur = n - 2, mlamp;
  while (!q.empty()) {
    int tp = q.top();
    q.pop();
    if (tp == a[0]) break;
    mlamp = a[cur];
    printf("%d %d\n", tp, mlamp);
    deg[mlamp]--;
    if (deg[mlamp] == 1) q.push(mlamp);
    --cur;
  }
  return 0;
}
