#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, i;
  bool is = true;
  cin >> n;
  vector<int> ns(n + 1), ord(n - 1);
  vector<pair<int, int> > edg(n - 1);
  for (i = 0; i < n - 1; i++) {
    cin >> ord[i];
    ns[ord[i]]++;
  }
  set<pair<int, int> > np;
  for (i = 1; i <= n; i++) {
    if (ns[i] == 0) np.insert(pair<int, int>(i, i));
  }
  for (i = ord.size() - 1; i >= 0; i--) {
    auto it = np.begin();
    if (it == np.end()) {
      is = false;
      break;
    }
    edg[i] = pair<int, int>(ord[i], (*it).second);
    ns[ord[i]]--;
    if (ns[ord[i]] == 0)
      np.insert(pair<int, int>(max(ord[i], (*it).first), ord[i]));
    np.erase(it);
  }
  if (is) {
    cout << ord[0] << "\n";
    for (i = 0; i < (int)edg.size(); i++)
      cout << edg[i].first << " " << edg[i].second << "\n";
  } else
    cout << "-1\n";
  return 0;
}
