#include <bits/stdc++.h>
using namespace std;
int n;
int a[210000];
int used[210000];
int main() {
  int n;
  cin >> n;
  int cur = n;
  n--;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  cout << a[1] << endl;
  used[a[1]] = 1;
  for (int i = 1; i <= n; i++) {
    while (used[cur]) cur--;
    if (used[a[i + 1]] || i == n) {
      cout << a[i] << ' ' << cur << endl;
      used[cur] = 1;
    } else {
      cout << a[i] << ' ' << a[i + 1] << endl;
      used[a[i + 1]] = 1;
    }
  }
  return ~~(0 ^ 0 ^ 0);
}
