#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 2e5 + 4;
bool used[N];
int main() {
  int n;
  scanf("%d", &n);
  int a[n - 1];
  for (int i = 0; i < n - 1; i++) scanf("%d", &a[i]);
  vector<pair<int, int>> v;
  printf("%d\n", a[0]);
  int val = n;
  used[a[0]] = 1;
  for (int i = 0; i < n - 2; i++) {
    if (used[a[i + 1]]) {
      while (used[val]) val--;
      v.emplace_back(a[i], val);
      used[a[i]] = 1;
      used[val] = 1;
    } else {
      v.emplace_back(a[i], a[i + 1]);
      used[a[i]] = 1;
      used[a[i + 1]] = 1;
    }
  }
  while (used[val]) val--;
  v.emplace_back(a[n - 2], val);
  for (auto it : v) printf("%d %d\n", it.first, it.second);
  return 0;
}
