#include <bits/stdc++.h>
using namespace std;
int n;
int f[200009];
long long a[200009];
long long ujf[200009];
set<pair<long long, int> > s;
vector<pair<int, int> > answer;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  for (long long i = 1; i <= n; i++) {
    ujf[i] = i;
    if (f[i] == 0) {
      s.insert({i, i});
    }
  }
  for (int i = n - 1; i >= 1; i--) {
    auto it = s.begin();
    pair<long long, int> akt = *it;
    answer.push_back({a[i], it->second});
    f[a[i]]--;
    ujf[a[i]] = max(ujf[a[i]], (it->first));
    if (f[a[i]] == 0) {
      s.insert({ujf[a[i]], (int)(a[i])});
    }
    s.erase(it);
  }
  cout << a[1] << endl;
  for (pair<int, int> p : answer) {
    cout << p.first << " " << p.second << endl;
  }
  return 0;
}
