#include <bits/stdc++.h>
using namespace std;
int c[202020];
int w[202020];
set<pair<int, int>> s;
vector<int> e[202020];
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    c[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    w[i] = i;
    if (c[i] == 0) {
      s.insert(make_pair(w[i], i));
    }
  }
  int x;
  for (int i = n - 2; i >= 0; i--) {
    x = s.begin()->second;
    s.erase(s.begin());
    e[a[i]].push_back(x);
    w[a[i]] = max(w[x], w[a[i]]);
    x = a[i];
    c[x]--;
    if (c[x] == 0) {
      s.insert(make_pair(w[x], x));
    }
  }
  cout << x << endl;
  for (int i = 1; i <= n; i++) {
    for (auto e : e[i]) {
      cout << e << " " << i << endl;
    }
  }
}
