#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e18;
const long long int MOD = (long long int)1e9 + 7;
const long long int maxn = (long long int)100002, L = 23;
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<vector<long long int>> gr(n);
  vector<long long int> a(n - 1);
  for (long long int i = 0; i < n - 1; ++i) {
    cin >> a[i];
    --a[i];
  }
  long long int root = a[0];
  vector<bool> used(n, 0);
  cout << root + 1 << endl;
  long long int now = n - 1;
  for (long long int i = 0; i < n - 1; ++i) {
    used[a[i]] = 1;
    while (used[now]) --now;
    if (i == n - 2 || used[a[i + 1]]) {
      cout << a[i] + 1 << " " << now + 1 << endl;
      used[now] = 1;
    } else
      cout << a[i + 1] + 1 << " " << a[i] + 1 << endl;
  }
  return 0;
}
