#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 43;
int a[N];
int n;
int deg[N];
int moment[N];
priority_queue<int, vector<int>, greater<int>> last;
void input() {
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    cin >> a[i];
    ++moment[a[i]];
  }
  for (int i = 1; i <= n; ++i) {
    deg[i] = 1 + moment[i];
    if (deg[i] == 1) last.push(i);
  }
  moment[a[1]]--;
}
void solve() {
  cout << a[1] << '\n';
  int curr = n - 1;
  while (curr >= 1) {
    int now = last.top();
    last.pop();
    deg[a[curr]]--;
    if (deg[a[curr]] == 1) last.push(a[curr]);
    cout << a[curr] << ' ' << now << '\n';
    --curr;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  input();
  solve();
  return 0;
}
