#include <bits/stdc++.h>
using namespace std;
struct Path {
  int val, lst;
  bool operator<(const Path &other) const { return val > other.val; }
};
int n;
priority_queue<Path> pq;
int v[200005];
bool ap[200005], can[200005];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> v[i];
    can[i] = (1 ^ ap[v[i]]);
    ap[v[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!ap[i]) pq.push({i, i});
  }
  cout << v[1] << "\n";
  for (int j = n - 1; j >= 1; j--) {
    int nod = pq.top().lst, val = pq.top().val;
    pq.pop();
    cout << v[j] << " " << nod << "\n";
    if (can[j]) pq.push({max(nod, v[j]), v[j]});
  }
  return 0;
}
