#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a;
  cin >> a;
  set<int, greater<int>, allocator<int> > out;
  auto it = out.end();
  for (int i = n; i >= 1; i--) {
    if (i != a) {
      it = out.insert(it, i);
    }
  }
  cout << a << '\n';
  int b;
  for (int i = 2; i <= n; i++) {
    if (i < n) {
      cin >> b;
    } else {
      b = *out.begin();
    }
    it = out.find(b);
    if (it == out.end()) {
      auto jt = out.begin();
      cout << a << ' ' << *jt << '\n';
      out.erase(jt);
    } else {
      cout << a << ' ' << b << '\n';
      out.erase(it);
    }
    a = b;
  }
}
