#include <bits/stdc++.h>
using namespace std;
;
void solve() {
  long long n;
  cin >> n;
  set<long long> tree, unused;
  for (long long i = 1; i <= n; i++) unused.insert(i);
  long long a[n - 1];
  vector<long long> g[n + 1];
  for (long long i = 0; i < n - 1; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n - 2; i++) {
    if (unused.find(a[i]) != (unused).end()) unused.erase(a[i]);
    auto it = (unused).end();
    it--;
    tree.insert(a[i]);
    if (tree.find(a[i + 1]) != (tree).end()) {
      g[a[i]].push_back(*it);
      unused.erase(it);
      tree.insert(*it);
    } else
      g[a[i]].push_back(a[i + 1]), unused.erase(a[i + 1]),
          tree.insert(a[i + 1]);
  }
  if ((long long)((unused).size())) g[a[n - 2]].push_back(*(unused).begin());
  cout << a[0] << '\n';
  for (long long i = 1; i <= n; i++) {
    for (auto j : g[i]) cout << i << " " << j << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  clock_t start, end;
  start = clock();
  cout << fixed << setprecision(20);
  while (t--) {
    solve();
  }
  end = clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
}
