#include <bits/stdc++.h>
using namespace std;
int n;
int a[200010], s[200010], m[200010];
int ans[200010][2];
struct node {
  int id, max;
  bool operator<(const node &T) const { return max > T.max; }
};
priority_queue<node> Q;
int main() {
  node now;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    s[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    m[i] = i;
    if (!s[i]) Q.push((node){i, i});
  }
  for (int i = 1; i < n; i++) {
    if (Q.empty()) {
      puts("-1");
      return 0;
    }
    now = Q.top();
    Q.pop();
    ans[i][0] = a[n - i];
    ans[i][1] = now.id;
    s[a[n - i]]--;
    m[a[n - i]] = max(m[a[n - i]], now.max);
    if (!s[a[n - i]]) Q.push((node){a[n - i], m[a[n - i]]});
  }
  printf("%d\n", a[1]);
  for (int i = 1; i < n; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
  return 0;
}
