#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7, mod = 1e9 + 7, INF = 0x3f3f3f3f;
int a[N];
int n;
bool vis[N];
int num[N];
int b[N];
int f(int x) { return x == b[x] ? x : b[x] = f(b[x]); }
void u(int x, int y) {
  x = f(x), y = f(y);
  if (x != y) b[x] = y;
}
int pre[N];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    if (pre[a[i]] == 0) pre[a[i]] = i;
    vis[a[i]] = 1;
  }
  priority_queue<int, vector<int>, greater<int> > q;
  for (int i = 1; i <= n; i++) {
    b[i] = i;
    if (!vis[i]) q.push(i);
    num[i] = i;
  }
  vector<pair<int, int> > ans;
  for (int i = n - 1; i >= 1; i--) {
    int x = q.top();
    q.pop();
    ans.push_back(pair<int, int>(num[x], a[i]));
    u(num[x], a[i]);
    x = max(x, a[i]);
    num[x] = a[i];
    if (i == pre[a[i]]) q.push(x);
  }
  for (int i = 2; i <= n; i++)
    if (f(i) != f(1)) {
      cout << -1;
      return 0;
    }
  cout << a[1] << '\n';
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  return 0;
}
