#include <bits/stdc++.h>
using namespace std;
int n, qntf[200123], v[200123], pai[200123], ancestral, ant;
struct cmpSet {
  bool operator()(int a, int b) { return pai[a] < pai[b]; }
};
set<int> folha;
set<int, cmpSet> zero;
vector<int> g[200123];
int id(int u) { return pai[u] = (pai[u] == u ? u : id(pai[u])); }
void unir(int a, int b) {
  a = id(a);
  b = id(b);
  if (a > b)
    pai[b] = a;
  else
    pai[a] = b;
}
void itZ() {
  cout << "ITERA SET" << endl;
  for (set<int, cmpSet>::iterator it = zero.begin(); it != zero.end(); it++) {
    cout << *it << " ";
  }
  cout << endl << "FIM" << endl;
}
int main() {
  cin >> n;
  cin >> ancestral;
  cout << ancestral << endl;
  v[0] = ancestral;
  qntf[ancestral]++;
  for (int i = 1; i < n - 1; i++) {
    cin >> v[i];
    qntf[v[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    pai[i] = i;
    if (!qntf[i]) zero.insert(i);
  }
  g[v[n - 2]].push_back(*zero.begin());
  zero.erase(*zero.begin());
  qntf[v[n - 2]]--;
  if (qntf[v[n - 2]] == 0) zero.insert(v[n - 2]);
  for (int i = n - 3; i >= 0; i--) {
    int no = v[i];
    if (!zero.empty()) {
      int umno = *zero.begin();
      zero.erase(pai[umno]);
      unir(no, umno);
      id(no);
      g[no].push_back(umno);
      qntf[no]--;
      if (qntf[no] == 0) {
        zero.insert(no);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (vector<int>::iterator j = g[i].begin(); j != g[i].end(); j++) {
      cout << i << " " << *j << endl;
    }
  }
}
