#include <bits/stdc++.h>
const int MAXN = 2e5 + 19;
int n, a[MAXN];
bool vist[MAXN];
int main() {
  std::scanf("%d", &n);
  for (int i = 1; i < n; ++i) std::scanf("%d", a + i);
  std::printf("%d\n", a[1]);
  for (int i = 1, j = n; i < n; ++i) {
    vist[a[i]] = true;
    if (i != n - 1 && !vist[a[i + 1]]) {
      std::printf("%d %d\n", a[i], a[i + 1]);
      vist[a[i + 1]] = true;
    } else {
      while (vist[j]) --j;
      vist[j] = true;
      std::printf("%d %d\n", a[i], j);
    }
  }
  return 0;
}
