#include <bits/stdc++.h>
using namespace std;
int fastio() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  return 0;
}
int __fastio = fastio();
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p);
template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A, B>& m) {
  os << "{";
  string sep = "";
  for (auto e : m) os << sep << e.first << ": " << e.second, sep = ", ";
  return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  string sep = "";
  for (auto e : v) os << sep << e, sep = ", ";
  return os << "]";
}
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p) {
  os << '(' << p.first << ", " << p.second << ')';
  return os;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
const int inf = 1000 << 20;
int main() {
  int n;
  cin >> n;
  vector<bool> vis(n + 1);
  int cur = n;
  vis[n] = 1;
  int prv = -1;
  for (int i = 0; i < n - 1; ++i) {
    int x;
    cin >> x;
    if (prv != -1) cout << prv << " ";
    if (vis[x]) {
      cout << cur << "\n";
      while (vis[cur]) --cur;
      vis[cur] = 1;
    } else {
      vis[x] = true;
      cout << x << "\n";
    }
    prv = x;
  }
  cout << prv << " " << cur << "\n";
}
