#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& cout, vector<T> V) {
  cout << "[ ";
  for (auto v : V) cout << v << ' ';
  return cout << ']';
}
template <class L, class R>
ostream& operator<<(ostream& cout, pair<L, R> P) {
  return cout << '(' << P.first << ',' << P.second << ')';
}
vector<vector<long long int>> conn;
vector<bool> v;
void dfs(long long int node, long long int par = -1) {
  v[node] = 1;
  for (long long int i : conn[node]) {
    if (i == par) continue;
    dfs(i, node);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> a(n - 1);
  for (long long int i = 0; i < (n - 1); i++) cin >> a[i];
  vector<pair<long long int, long long int>> ans;
  if (a[0] == n) {
    ans.push_back({a[0], n - 1});
  } else {
    ans.push_back({a[0], n});
  }
  vector<long long int> done(n + 1);
  done[ans[0].first]++;
  done[ans[0].second]++;
  long long int curr = n;
  priority_queue<long long int> pq;
  for (long long int i = 0; i < (n); i++) pq.push(i + 1);
  for (long long int i = 1; i < n - 1; i++) {
    while (done[pq.top()]) pq.pop();
    curr = pq.top();
    if (!done[a[i]]) {
      pair<long long int, long long int> temp = ans.back();
      ans[ans.size() - 1] = {temp.first, a[i]};
      done[temp.second]--;
      if (done[temp.second] == 0) pq.push(temp.second);
      if (pq.top() > curr) {
        pq.push(curr);
        curr = pq.top();
        pq.pop();
      }
      temp.first = a[i];
      temp.second = curr;
      ans.push_back(temp);
    } else {
      ans.push_back({a[i], curr});
    }
    done[curr]++;
    done[a[i]]++;
  }
  v.resize(n);
  conn.resize(n);
  for (long long int i = 0; i < (n - 1); i++) {
    conn[ans[i].first - 1].push_back(ans[i].second - 1);
    conn[ans[i].second - 1].push_back(ans[i].first - 1);
  }
  dfs(0);
  for (long long int i = 0; i < (n); i++) {
    if (!v[i]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << a[0] << '\n';
  for (long long int i = 0; i < (n - 1); i++)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  ;
}
