#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long m = 1000000007) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long res = power(a, b / 2, m);
  res = (res * res) % m;
  if (b & 1) res = (res * a) % m;
  return res;
}
long long modinv(long long a, long long m = 1000000007) {
  return power(a, m - 2, m);
}
long long add(long long a, long long b, long long m = 1000000007) {
  return (a + b) % m;
}
long long sub(long long a, long long b, long long m = 1000000007) {
  return (a - b + m) % m;
}
long long mul(long long a, long long b, long long m = 1000000007) {
  return (a * b) % m;
}
void solve() {
  long long n, i;
  cin >> n;
  long long a[n], visit[n + 1];
  memset(visit, 0, sizeof(visit));
  for (i = 0; i < n - 1; i++) cin >> a[i];
  long long root = a[0], cur = n;
  cout << root << "\n";
  for (i = 0; i < n - 1; i++) {
    visit[a[i]] = 1;
    while (visit[cur]) cur--;
    if (i == n - 2 || visit[a[i + 1]]) {
      cout << a[i] << " " << cur << "\n";
      visit[cur] = 1;
    } else
      cout << a[i] << " " << a[i + 1] << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) solve();
  return 0;
}
