#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  vector<int> children(n + 1, 0);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    ++children[a[i]];
  }
  vector<int> parent(n + 1, 0);
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  for (int i = 1; i <= n; i++) {
    if (children[i] == 0) pq.push({i, i});
  }
  int flag = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (pq.empty()) {
      cout << "-1\n";
      return 0;
    }
    pair<int, int> z = pq.top();
    pq.pop();
    parent[z.second] = a[i];
    --children[a[i]];
    if (children[a[i]] == 0) pq.push({max(z.first, a[i]), a[i]});
  }
  int root = 0;
  for (int i = 1; i <= n; i++) {
    if (parent[i] == 0) {
      if (root > 0) {
        cout << "-1\n";
        return 0;
      }
      root = i;
    }
  }
  cout << root << endl;
  for (int i = 1; i <= n; i++) {
    if (i != root) cout << i << " " << parent[i] << "\n";
  }
}
