#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int a[N];
int per[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &a[i]);
  }
  int ls = a[0];
  set<int> st;
  for (int i = 1; i <= n; i++) {
    st.insert(i);
  }
  for (int i = 0; i < n - 1; i++) {
    if (per[a[i]]) {
      ls = *(--st.end());
      st.erase(--st.end());
      per[ls] = a[i];
    } else {
      st.erase(a[i]);
      per[a[i]] = per[ls];
      per[ls] = a[i];
      if (i == 0) i--;
    }
  }
  printf("%d\n", a[0]);
  for (int i = 1; i <= n; i++) {
    if (per[i] == i) continue;
    printf("%d %d\n", i, per[i]);
  }
  return 0;
}
