#include <bits/stdc++.h>
const long long N = 105;
const long long M = 2e4 + 5;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const long long inf = 0x7fffffff;
const double pi = 3.1415926;
using namespace std;
using namespace std;
const long long maxn = 200010;
long long n, a[maxn], deg[maxn], pos[maxn], to[maxn], val[maxn];
struct Node {
  long long x, val;
  bool operator<(const Node x) const { return x.val < val; }
};
priority_queue<Node> que;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  scanf("%d", &n);
  for (long long i = 1; i < n; i++) scanf("%d", &a[i]), deg[a[i]]++;
  for (long long i = 1; i <= n; i++) val[i] = i;
  for (long long i = 1; i <= n; i++)
    if (!deg[i]) {
      Node x;
      x.x = i;
      x.val = val[i];
      que.push(x);
    }
  for (long long i = n - 1; i >= 1; i--) {
    if (que.size() == 0) {
      cout << -1;
      return 0;
    }
    Node x = que.top();
    long long u = x.x;
    val[a[i]] = max(val[a[i]], val[u]);
    que.pop();
    pos[i] = u;
    to[i] = a[i];
    deg[a[i]]--;
    if (!deg[a[i]]) {
      Node v;
      v.val = val[a[i]];
      v.x = a[i];
      que.push(v);
    }
  }
  if (que.size() > 1) {
    cout << -1;
    return 0;
  }
  cout << a[1] << endl;
  for (long long i = 1; i < n; i++) cout << pos[i] << " " << to[i] << endl;
  return 0;
}
