#include <bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, greater<int>> q;
int a[200002], vis[200002];
vector<pair<int, int>> v;
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &x);
    vis[x]++;
    a[i] = x;
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) q.push(i);
  }
  for (int i = n - 1; i > 0 && !q.empty(); i--) {
    x = q.top();
    q.pop();
    v.push_back({a[i], x});
    if ((--vis[a[i]]) == 0) q.push(a[i]);
  }
  printf("%d\n", a[1]);
  for (int i = 0; i < n - 1; i++) printf("%d %d\n", v[i].first, v[i].second);
  return 0;
}
