#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
vector<pair<int, int> > ans;
int deg[N + 100], a[N + 100], mx[N + 100];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", a + i);
    deg[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    mx[i] = i;
    if (deg[i] == 0) {
      pq.push(make_pair(i, i));
    }
  }
  int cur = n - 1;
  while (cur > 0) {
    pair<int, int> A = pq.top();
    pq.pop();
    int v = A.second;
    int u = a[cur];
    ans.push_back(make_pair(u, v));
    mx[u] = max(mx[u], A.first);
    deg[u]--;
    if (deg[u] == 0) {
      pq.push(make_pair(mx[u], u));
    }
    cur--;
  }
  printf("%d\n", a[1]);
  for (auto it : ans) {
    printf("%d %d\n", it.first, it.second);
  }
}
