#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  for (; b; a %= b, swap(a, b))
    ;
  return a;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); };
int dr[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dc[] = {1, 0, -1, 0, 1, -1, 1, -1};
int n, m, k, t;
int a[200001];
bool ch[200001];
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  vector<pair<int, int> > ans;
  int idx = n;
  for (int i = 1; i < n; i++) {
    ch[a[i]] = 1;
    while (ch[idx]) idx--;
    pair<int, int> e;
    if (i == n - 1 || ch[a[i + 1]]) {
      e = {a[i], idx};
      ch[idx] = 1;
    } else
      e = {a[i + 1], a[i]};
    ans.push_back(e);
  }
  cout << a[1] << '\n';
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  }
  return 0;
}
