#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, start;
  cin >> n;
  set<pair<int, int>> q;
  for (int i = 1; i <= n; i++) q.insert(make_pair(i, i));
  stack<int> d;
  stack<pair<int, int>> ans;
  vector<int> check(n + 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> t;
    check[t]++;
    d.push(t);
    q.erase(make_pair(t, t));
  }
  while (!d.empty()) {
    int v = d.top(), hmm = q.begin()->second, cost = q.begin()->first;
    q.erase(make_pair(cost, hmm));
    d.pop();
    ans.push(make_pair(hmm, v));
    check[v]--;
    if (check[v] == 0) q.insert(make_pair(max(v, cost), v));
    if (d.empty()) start = v;
  }
  cout << start << endl;
  while (!ans.empty()) {
    cout << ans.top().first << " " << ans.top().second << endl;
    ans.pop();
  }
}
