#include <bits/stdc++.h>
const int N = (int)1e5 + 7;
const int MOD = (int)1e9 + 7;
const long long INF = (long long)1e18;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> A(n + 1), R(n + 1);
  for (int i = 1; i <= n; i++) cin >> A[i];
  int y = n + 1;
  set<vector<int>> S, T;
  bool ok = true;
  for (int i = n; i > 0; i--) {
    if (A[i] == 0) continue;
    if (A[i] == 1) {
      y--;
      S.insert({i, y});
      T.insert({-A[i], i, y});
    } else if (A[i] == 2) {
      auto it = T.lower_bound({-1, 0, 0});
      if (it == T.end()) {
        ok = false;
        break;
      }
      int h = (*it)[2];
      T.erase(it);
      S.insert({i, h});
      T.insert({-A[i], i, h});
    } else if (A[i] == 3) {
      auto it = T.begin();
      if (it == T.end()) {
        ok = false;
        break;
      }
      int j = (*it)[1], h = (*it)[2];
      T.erase(it);
      y--;
      S.insert({j, y});
      S.insert({i, y});
      T.insert({-A[i], i, y});
    }
  }
  for (auto p : S) {
    R[p[1]]++;
    if (R[p[1]] > 2 || p[0] < 1 || p[0] > n || p[1] < 0 || p[1] > n) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << S.size() << '\n';
    for (auto s : S) {
      cout << s[1] << ' ' << s[0] << '\n';
    }
  } else {
    cout << "-1\n";
  }
  return 0;
}
