#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + c - 48;
    c = getchar();
  }
  return x * f;
}
int k, m, n;
priority_queue<pair<int, int>> q;
int vis[maxn], a[maxn], max_[maxn];
pair<int, int> ans[maxn];
int main() {
  n = read();
  for (register int i = 1; i < n; i++) {
    a[i] = read();
    vis[a[i]]++;
  }
  printf("%d\n", a[1]);
  for (register int i = 1; i <= n; i++) {
    max_[i] = i;
    if (!vis[i]) q.push(make_pair(-i, i));
  }
  for (register int i = n - 1; i >= 1; i--) {
    int x = q.top().second;
    q.pop();
    ans[i] = make_pair(a[i], x);
    max_[a[i]] = max(max_[a[i]], max_[x]);
    vis[a[i]]--;
    if (!vis[a[i]]) q.push(make_pair(-max_[a[i]], a[i]));
  }
  for (register int i = 1; i < n; i++) printf("%d %d\n", a[i], ans[i].second);
  return 0;
}
