#include <bits/stdc++.h>
using namespace std;
int n, a[200005], son[200005], Max[200005];
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
pair<int, int> edge[200005];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i], son[a[i]]++;
  for (int i = 1; i <= n; i++) Max[i] = i;
  for (int i = 1; i <= n; i++)
    if (!son[i]) s.insert(make_pair(Max[i], i));
  for (int i = n - 1; i >= 1; i--) {
    it = s.begin();
    edge[i].first = a[i];
    edge[i].second = (*it).second;
    son[a[i]]--;
    Max[a[i]] = max(Max[(*it).second], Max[a[i]]);
    if (son[a[i]] == 0) s.insert(make_pair(Max[a[i]], a[i]));
    s.erase(it);
  }
  cout << a[1] << '\n';
  for (int i = 1; i < n; i++)
    cout << edge[i].first << " " << edge[i].second << '\n';
}
