#include <bits/stdc++.h>
using namespace std;
void program();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  program();
}
const int MX = 1e6;
int n, a[MX];
int root;
bitset<MX> used;
vector<pair<int, int> > ans;
void program() {
  cin >> n;
  for (int i = int(0); i < int(n - 1); i++) cin >> a[i];
  root = a[0];
  used.reset();
  used[root] = 1;
  int m = n;
  int e = 0;
  while (1) {
    while (used[m]) m--;
    if (m == 0) break;
    used[m] = 1;
    int b = e;
    for (int i = int(b + 1); i < int(n - 1); i++) {
      if (used[a[i]]) {
        e = i;
        break;
      }
      used[a[i]] = 1;
    }
    if (b == e) e = n - 1;
    for (int i = int(b); i < int(e - 1); i++) ans.push_back({a[i], a[i + 1]});
    ans.push_back({a[e - 1], m});
  }
  cout << root << endl;
  for (int i = int(0); i < int(n - 1); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
