#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long a[n - 1];
  for (long long i = 0; i < n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  long long b[n];
  for (long long i = 0; i < n; i++) b[i] = 0;
  vector<pair<long long, long long>> v;
  long long l = n - 1;
  for (long long i = 0; i < n - 1; i++) {
    b[a[i]] = 1;
    while (b[l]) l--;
    if (b[l] == 1) {
      cout << "-1";
      return 0;
    }
    if (i == n - 2 || b[a[i + 1]]) {
      v.push_back({a[i] + 1, l + 1});
      b[l] = 1;
    } else
      v.push_back({a[i + 1] + 1, a[i] + 1});
  }
  cout << a[0] + 1 << endl;
  for (long long i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
  return 0;
}
