#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1), vis(n + 1);
  for (int i = 0; i < n - 1; i++) cin >> a[i], vis[a[i]]++;
  int rt = a[0];
  priority_queue<int, vector<int>, greater<int>> q;
  for (int i = 1; i <= n; i++)
    if (vis[i] == 0) q.push(i);
  reverse(a.begin(), a.end());
  vector<pair<int, int>> ans;
  for (int x : a) {
    int tp = q.top();
    q.pop();
    ans.push_back({tp, x});
    if (--vis[x] == 0) q.push(x);
  }
  cout << rt << endl;
  for (auto [u, v] : ans) cout << u << " " << v << endl;
}
