#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
int a[maxn], vis[maxn];
set<int> s;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    s.insert(i);
    vis[i] = 0;
  }
  printf("%d\n", a[1]);
  vis[a[1]] = 1;
  s.erase(a[1]);
  int po = 1;
  for (int i = 2; i <= n - 1; i++) {
    if (!vis[a[i]]) {
      printf("%d %d\n", a[po], a[i]);
      vis[a[i]] = 1;
      s.erase(a[i]);
      po++;
    } else if (vis[a[i]] == 1) {
      int now = *(--s.end());
      printf("%d %d\n", a[po], now);
      vis[now] = 1;
      s.erase(now);
      po++;
    }
  }
  for (int i = po; i <= n - 1; i++) {
    int now = *(--s.end());
    printf("%d %d\n", a[i], now);
    s.erase(now);
  }
}
