#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> adj[n + 1], childs(n + 1), v(n - 1);
  for (int i = 0; i < n - 1; i++) cin >> v[i];
  int root = v[0];
  for (int i = 0; i < n - 1; i++) childs[v[i]]++;
  priority_queue<int, vector<int>, greater<int> > q;
  for (int i = 1; i <= n; i++)
    if (!childs[i]) q.push(i);
  int ptr = n - 2;
  while (ptr >= 0) {
    adj[v[ptr]].push_back(q.top());
    q.pop();
    childs[v[ptr]]--;
    if (!childs[v[ptr]]) q.push(v[ptr]);
    ptr--;
  }
  cout << root << '\n';
  for (int i = 1; i <= n; i++)
    for (int j : adj[i]) cout << i << ' ' << j << '\n';
  return 0;
}
