#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, cnt[maxn];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  vector<int> ord, cnt(n + 1, 0);
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    ord.push_back(a);
    cnt[a]++;
  }
  set<int> leaves;
  for (int i = 1; i <= n; i++)
    if (!cnt[i]) leaves.insert(i);
  vector<pair<int, int> > ans;
  while ((int)ord.size()) {
    int cur = ord.back();
    ord.pop_back();
    if (!(int)leaves.size()) return cout << "-1\n", 0;
    ans.push_back({cur, *leaves.begin()});
    cnt[cur]--;
    leaves.erase(leaves.begin());
    if (!cnt[cur]) {
      leaves.insert(cur);
    }
  }
  if ((int)leaves.size() != 1) return cout << "-1\n", 0;
  cout << *leaves.begin() << "\n";
  reverse(ans.begin(), ans.end());
  for (pair<int, int> p : ans) cout << p.first << " " << p.second << "\n";
  return 0;
}
