#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n - 1);
  for (int i = 0; i < (int)n - 1; ++i) {
    cin >> a[i];
    a[i]--;
  }
  long long root = a[0];
  cout << root + 1 << endl;
  vector<long long> deg(n, 0);
  for (int i = 0; i < (int)n - 1; ++i) deg[a[i]]++;
  vector<long long> w(n, 0);
  for (int i = 0; i < (int)n; ++i) w[i] = i;
  set<pair<long long, long long>> st;
  for (int i = 0; i < (int)n; ++i) {
    if (deg[i] == 0) {
      st.insert({i, i});
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    auto itr = st.begin();
    cout << itr->second + 1 << " " << a[i] + 1 << endl;
    w[a[i]] = max(w[a[i]], itr->first);
    st.erase(itr);
    deg[a[i]]--;
    if (deg[a[i]] == 0) st.insert({w[a[i]], a[i]});
  }
  return 0;
}
