#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
bool flag[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) cin >> a[i];
  cout << a[1] << endl;
  int cur = n;
  for (int i = 1; i < n; ++i) {
    flag[a[i]] = true;
    while (flag[cur]) --cur;
    if (i == n - 1 || flag[a[i + 1]]) {
      cout << a[i] << " " << cur << endl;
      flag[cur] = true;
    } else {
      cout << a[i] << " " << a[i + 1] << endl;
    }
  }
  return 0;
}
