#include <bits/stdc++.h>
using namespace std;
vector<bool> vis;
vector<vector<long long>> adj;
void dfs(long long node) {
  vis[node] = true;
  for (long long child : adj[node]) {
    if (vis[child]) continue;
    dfs(child);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> arr(n - 1);
  vector<long long> deg(n + 1, 1);
  for (long long i = 0; i < n - 1; ++i) {
    cin >> arr[i];
    ++deg[arr[i]];
  }
  set<pair<long long, long long>> st;
  for (long long i = 1; i <= n; ++i) {
    if (deg[i] == 1) {
      st.insert({i, i});
    }
  }
  cout << arr[0] << '\n';
  for (long long i = n - 2; i >= 0; --i) {
    const long long node = arr[i];
    auto it = st.begin();
    long long currMx = it->first;
    long long currRoot = it->second;
    st.erase(it);
    cout << currRoot << " " << node << '\n';
    --deg[node];
    if (deg[node] == 1) {
      st.insert({max(currMx, node), node});
    }
  }
}
