#include <bits/stdc++.h>
using namespace std;
int ar[1000007], cnt[1000007], opt[1000007];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
vector<pair<int, int> > v;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> ar[i];
    cnt[ar[i]]++;
    opt[ar[i]] = ar[i];
  }
  for (int i = 1; i <= n; i++) {
    if (!cnt[i]) q.push({i, i});
  }
  for (int i = n - 1; i >= 1; i--) {
    int nx = ar[i];
    int lastx = q.top().second;
    int x = q.top().first;
    q.pop();
    cnt[nx]--;
    if (cnt[nx] == 0) {
      v.push_back({nx, lastx});
      q.push({max(opt[nx], x), nx});
    } else {
      opt[nx] = max(opt[nx], x);
      v.push_back({nx, lastx});
    }
    if (q.empty()) {
      cout << -1;
      return 0;
    }
  }
  cout << ar[1];
  cout << "\n";
  for (auto it : v) {
    cout << it.first << " " << it.second;
    cout << "\n";
  }
  return 0;
}
