#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 2e5 + 100;
struct node;
struct node_cmp {
  inline bool operator()(node *a, node *b) const;
};
priority_queue<node *, vector<node *>, node_cmp> pq;
struct node {
  int weight, idx, x;
  bool conencted = false;
  bool not_leaf;
  vector<node *> adj;
  void print() {
    for (auto nd : adj) {
      cout << idx << ' ' << nd->idx << '\n';
      nd->print();
    }
  }
  void connect() {
    x--;
    auto nd = pq.top();
    nd->conencted = true;
    pq.pop();
    adj.push_back(nd);
    weight = max(weight, nd->weight);
    if (x == 0) {
      pq.push(this);
    }
  }
} nodes[N];
inline bool node_cmp::operator()(node *a, node *b) const {
  return a->weight > b->weight;
}
int n, order[N];
bool f[N];
int main() {
  ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> order[i];
    nodes[order[i]].x++;
  }
  for (int i = 1; i <= n; i++) {
    auto &nd = nodes[i];
    nd.weight = nd.idx = i;
    if (nd.x == 0) {
      pq.push(&nd);
    }
  }
  nodes[order[1]].weight = N * 3;
  for (int i = n - 1; i >= 1; i--) {
    nodes[order[i]].connect();
  }
  cout << order[1] << '\n';
  nodes[order[1]].print();
}
