#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int cnt[200005];
int a[200005];
void solve() {
  ll i, j;
  ll n;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  set<int> s;
  for (i = 1; i <= n; i++) {
    if (cnt[i] == 0) s.insert((int)i);
  }
  vector<pair<int, int>> ans;
  for (i = n - 1; i >= 1; i--) {
    if (s.empty()) {
      cout << -1;
      return;
    }
    int cur = *s.begin();
    s.erase(s.begin());
    ans.push_back({cur, a[i]});
    if (--cnt[a[i]] == 0) s.insert(a[i]);
  }
  if (s.empty()) {
    cout << -1;
    return;
  }
  cout << a[1] << '\n';
  for (i = (int)ans.size() - 1; i >= 0; i--)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
}
