#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
long long deg[2 * 100002];
int main() {
  long long n;
  cin >> n;
  vector<long long> v;
  for (long long i = 1; i <= (long long)(n); ++i) deg[i] = 1;
  for (long long i = 0; i < (long long)(n - 1); ++i) {
    long long a;
    cin >> a;
    v.push_back(a);
    deg[a]++;
  }
  priority_queue<long long, vector<long long>, greater<long long>> q;
  for (long long i = 1; i <= (long long)(n); ++i) {
    if (deg[i] == 1) q.push(i);
  }
  cout << v[0] << "\n";
  for (long long i = n - 2; i >= 0; i--) {
    long long tp = q.top();
    q.pop();
    deg[v[i]]--;
    cout << tp << " " << v[i] << "\n";
    if (deg[v[i]] == 1) q.push(v[i]);
  }
}
