#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6 + 10, M = 2e6 + 10, mod = 1e9 + 7, inf = 0x3f3f3f;
long long a[N], de[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int _;
  _ = 1;
  while (_--) {
    long long n;
    cin >> n;
    for (int i = 1; (i) <= (n - 1); i++) cin >> a[i], de[a[i]]++;
    int root = a[1], now = n;
    priority_queue<int, vector<int>, greater<int> > q;
    for (int i = 1; (i) <= (n); i++)
      if (!de[i]) q.push(i);
    cout << root << '\n';
    while (q.size()) {
      int x = a[--now];
      int y = q.top();
      q.pop();
      if (!now) break;
      cout << x << ' ' << y << '\n';
      de[x]--;
      if (!de[x]) q.push(x);
    }
  }
  return 0;
}
