#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 6;
int n;
int num[N];
int m[N] = {0};
int main() {
  priority_queue<int> que;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d", &num[i]);
    m[num[i]]++;
  }
  for (int i = 1; i <= n; i++)
    if (!m[i]) que.push(-i);
  printf("%d\n", num[1]);
  for (int i = n - 1; i >= 1; i--) {
    int x = -que.top();
    que.pop();
    printf("%d %d\n", x, num[i]);
    m[num[i]]--;
    if (m[num[i]] == 0) que.push(-num[i]);
  }
}
