#include <bits/stdc++.h>
using namespace std;
template <class T, size_t... Is>
struct arr_helper;
template <class T, size_t... Is>
using arr = typename arr_helper<T, Is...>::type;
template <class T>
struct arr_helper<T> {
  using type = T;
};
template <class T, size_t I, size_t... Is>
struct arr_helper<T, I, Is...> {
  using type = array<arr<T, Is...>, I>;
};
using ll = long long;
using u64 = uint64_t;
using u32 = uint32_t;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pi>;
[[maybe_unused]] const int INF = (int)1e9;
[[maybe_unused]] const ll INFL = (ll)1e18;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<bool> known(n);
  int root;
  cin >> root;
  --root;
  int last = root;
  int path_to = root == n - 1 ? n - 2 : n - 1;
  known[root] = true;
  vpi e;
  for (int _ = 0; _ < (n - 2); ++_) {
    int v;
    cin >> v;
    --v;
    if (known[v] || v == path_to) {
      e.emplace_back(last, path_to);
      known[path_to] = true;
      while (known[path_to]) --path_to;
      last = v;
    } else {
      e.emplace_back(last, v);
      last = v;
      known[v] = true;
    }
  }
  e.emplace_back(last, path_to);
  cout << (root + 1) << '\n';
  for (auto [a, b] : e) cout << (a + 1) << ' ' << (b + 1) << '\n';
  return 0;
}
