#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
int vis[maxn];
struct Node {
  int x, y;
  Node() {}
  Node(int a, int b) {
    x = a;
    y = b;
  }
};
vector<Node> ans;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) scanf("%d", &a[i]);
  printf("%d\n", a[1]);
  vis[a[1]] = 1;
  int son = n;
  for (int i = 2; i < n; ++i) {
    if (!vis[a[i]])
      ans.push_back(Node(a[i], a[i - 1])), vis[a[i]] = 1;
    else {
      while (vis[son]) {
        son--;
      }
      vis[son] = 1;
      ans.push_back(Node(a[i - 1], son));
    }
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      ans.push_back(Node(a[n - 1], i));
      break;
    }
  for (int i = 0; i < ans.size(); ++i) printf("%d %d\n", ans[i].x, ans[i].y);
  return 0;
}
