#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626433832795;
const long long INF = 1LL << 62;
const long long MINF = -1LL << 62;
template <typename T>
T getint() {
  T val = 0;
  char c;
  bool neg = false;
  while ((c = getchar()) && !(c >= '0' && c <= '9')) {
    neg |= c == '-';
  }
  do {
    val = (val * 10) + c - '0';
  } while ((c = getchar()) && (c >= '0' && c <= '9'));
  return val * (neg ? -1 : 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n - 1; ++i) cin >> t[i];
  map<int, int> cnt;
  set<int> nem;
  for (int i = 1; i <= n; ++i) nem.insert(i);
  for (auto i : t) {
    cnt[i]++;
    if (cnt[i] == 1) nem.erase(i);
  }
  vector<pair<int, int>> lst;
  for (int i = n - 2; i >= 0; i--) {
    int akt = t[i];
    cnt[akt]--;
    lst.push_back({t[i], *nem.begin()});
    nem.erase(nem.begin());
    if (cnt[akt] == 0) {
      nem.insert(akt);
    }
  }
  cout << t[0] << "\n";
  for (auto i : lst) cout << i.first << " " << i.second << "\n";
  return 0;
}
