#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int now, last, top;
bool used[maxn] = {0};
void updl() {
  for (int i = last; i >= 1; i--) {
    if (!used[i]) {
      last = i;
      return;
    }
  }
  last = 0;
}
void edge(int x, int y) { cout << x << " " << y << endl; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int cnt, temp;
  cin >> cnt;
  cin >> temp;
  used[temp] = true;
  now = temp;
  last = cnt;
  updl();
  cout << temp << endl;
  for (int i = 1; i < cnt - 1; i++) {
    cin >> temp;
    if (used[temp]) {
      edge(now, last);
      used[last] = true;
      updl();
      now = temp;
    } else {
      edge(now, temp);
      used[temp] = true;
      if (temp == last) updl();
      now = temp;
    }
  }
  updl();
  edge(now, last);
  return 0;
}
