var stdin = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n').filter(s => s);
var b = stdin.pop().split(' ').map(n => +n);

function resolve(a, b) {
  if (b.length === 0) {
    return a.join('\n');
  }
  if (b.some(n => n > b.length)) {
    return;
  }
  var ans;
  b
    .filter((n, i) => n === i + 1)
    .some((n) => {
      var t = resolve([n, ...a], [...b.slice(0, n - 1), ...b.slice(n)]);
      if (t) {
        ans = t;
        return true;
      }
    });
  return ans;
}

console.log(resolve([], b) || -1);
