#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using i3 = pair<int, ii>;
using li = pair<ll, int>;
using lii = pair<ll, ii>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<ii>;
using vli = vector<li>;
using vpll = vector<pll>;
using vi3 = vector<i3>;
using vlii = vector<lii>;
const int N = 2e5 + 5;
const int INF = 1e9 + 7;
const double eps = 1e-9, PI = acos(-1);
int n, m;
int in[N];
int a[N];
void solve(int testCase) {
  scanf("%d", &n);
  priority_queue<int, vi, greater<int> > pq;
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    in[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (!in[i]) pq.push(i);
  }
  printf("%d\n", a[1]);
  for (int i = n - 1; i >= 1; i--) {
    int nxt = pq.top();
    pq.pop();
    printf("%d %d\n", a[i], nxt);
    in[a[i]]--;
    if (!in[a[i]]) pq.push(a[i]);
  }
}
int main() {
  int t = 1;
  for (int testCase = 1; testCase <= t; testCase++) {
    solve(testCase);
  }
  return 0;
}
