#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int indexes[maxn];
int n;
int parent[maxn];
int cnt[maxn];
set<int> s;
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    cin >> indexes[i];
    cnt[indexes[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (cnt[i]) continue;
    s.insert(i);
  }
  int idx = n - 1;
  parent[indexes[1]] = indexes[1];
  while (!s.empty()) {
    int u = *s.begin();
    s.erase(s.begin());
    int v = indexes[idx--];
    parent[u] = v;
    cnt[v]--;
    if (cnt[v]) continue;
    if (v == indexes[1]) continue;
    s.insert(v);
  }
  for (int i = 1; i <= n; ++i) {
    if (parent[i] == 0) {
      return cout << -1 << endl, 0;
    }
  }
  cout << indexes[1] << endl;
  for (int i = 1; i <= n; ++i) {
    if (parent[i] == i) continue;
    cout << i << " " << parent[i] << endl;
  }
}
