#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n + 1];
  memset(a, 0, sizeof(a));
  long long c[n];
  for (long long i = 0; i < n - 1; i = i + 1) {
    cin >> c[i];
    a[c[i]]++;
  }
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  for (long long i = 1; i < n + 1; i = i + 1)
    if (a[i] == 0) pq.push(pair<long long, long long>(i, i));
  long long w[n + 1];
  for (long long i = 0; i < n + 1; i = i + 1) w[i] = i;
  cout << c[0] << endl;
  for (long long i = n - 2; i >= 0; i--) {
    pair<long long, long long> u = pq.top();
    pq.pop();
    cout << c[i] << " " << u.second << endl;
    ;
    a[c[i]]--;
    w[c[i]] = max(u.first, w[c[i]]);
    if (a[c[i]] == 0) {
      pq.push(pair<long long, long long>(w[c[i]], c[i]));
    }
  }
}
