#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
template <typename T>
T gcd(T a, T b) {
  return (a == 0) ? b : gcd(b % a, a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
bool p_comp_fs(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first < p2.first;
};
bool p_comp_fg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first > p2.first;
};
bool p_comp_ss(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second < p2.second;
};
bool p_comp_sg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second > p2.second;
};
template <typename T>
vector<T> uniquen(vector<T> vec) {
  sort((vec).begin(), (vec).end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
inline long long popcnt(long long x) {
  return __builtin_popcountll((unsigned long long)x);
};
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
bool bit(long long st, long long b) { return ((st >> b) & 1) == 1; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N;
  cin >> N;
  stack<long long> st;
  long long root = -1;
  vector<long long> deg(N + 1, 1);
  deg[0] = 0;
  for (long long i = 0; i < N - 1; i++) {
    long long x;
    cin >> x;
    st.push(x);
    if (i == 0) root = x;
    deg[x]++;
  }
  deg[root] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  vector<long long> state(N + 1, 0);
  for (long long i = 0; i < N + 1; i++)
    if (deg[i] == 1) {
      pq.push({i, i});
      state[i] = i;
    }
  vector<pair<long long, long long>> ans;
  set<pair<long long, long long>> used;
  while (ans.size() < N - 1) {
    if (pq.empty()) {
      cout << -1 << endstr;
      return 0;
    }
    long long now = pq.top().first, num = pq.top().second;
    pq.pop();
    long long to = st.top();
    if (num == to) {
      cout << -1 << endstr;
      return 0;
    }
    long long mn = min(num, to), mx = max(num, to);
    if (used.count({mn, mx}) > 0) {
      cout << -1 << endstr;
      return 0;
    }
    used.insert({mn, mx});
    ans.push_back({mn, mx});
    st.pop();
    deg[num]--;
    deg[to]--;
    chmax(state[to], max(now, to));
    if (to != root && deg[to] == 1) {
      pq.push({state[to], to});
    }
  }
  if (!pq.empty()) {
    cerr << "not empty" << endstr;
  }
  cout << root << endstr;
  for (long long i = 0; i < N - 1; i++) {
    cout << ans[i].first << " " << ans[i].second << endstr;
  }
  return 0;
}
