#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
int32_t main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<long long> used(n + 1), a(n);
  long long mx = n;
  for (long long i = 0; i < n - 1; i++) {
    cin >> a[i];
  }
  cout << a[0] << endl;
  for (long long i = 0; i < n - 1; i++) {
    used[a[i]] = 1;
    if (i < n - 2 && !used[a[i + 1]]) {
      cout << a[i] << " " << a[i + 1] << endl;
    } else {
      while (used[mx]) mx--;
      cout << a[i] << " " << mx << endl;
      used[mx] = 1;
    }
  }
}
