#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N - 1);
  for (int i = 0; i < (N - 1); ++i) cin >> A[i];
  for (int i = 0; i < (N - 1); ++i) A[i]--;
  vector<int> ans(N - 1, -1);
  vector<int> used(N, 0);
  int K = A[0];
  used[K] = 1;
  int tar = N - 1;
  for (int i = 0; i < N - 1; i++) {
    while (tar >= 0 && used[tar]) tar--;
    if (used[A[i]] == 0) {
      used[A[i]] = 1;
      ans[i - 1] = A[i];
    } else {
      if (i == 0) continue;
      used[tar] = 1;
      ans[i - 1] = tar;
    }
  }
  while (tar >= 0 && used[tar]) tar--;
  ans[N - 2] = tar;
  cout << K + 1 << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << A[i] + 1 << " " << ans[i] + 1 << endl;
  return 0;
}
