#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> e(n - 1);
  vector<int> cnt(n + 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> e[i];
    ++cnt[e[i]];
  }
  using PII = pair<int, int>;
  priority_queue<PII, vector<PII>, greater<PII>> Q;
  for (int i = 1; i <= n; i++) {
    if (!cnt[i]) {
      Q.push(make_pair(i, i));
    }
  }
  vector<pair<int, int>> ans;
  for (int i = n - 2; i >= 0; i--) {
    if (Q.empty()) {
      cout << -1 << endl;
      exit(0);
    }
    pair<int, int> cur = Q.top();
    Q.pop();
    ans.push_back(make_pair(e[i], cur.second));
    --cnt[e[i]];
    if (!cnt[e[i]]) {
      Q.push(make_pair(max(e[i], cur.first), e[i]));
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans[0].first << endl;
  for (auto t : ans) {
    cout << t.first << " " << t.second << endl;
  }
  return 0;
}
