#!/usr/local/bin/ruby class BipartiteMatching def initialize(n,adj) @n,@adj = n,adj # adj is already satisfied with bipartite property. end private def dfs(v) rop = false @visited[v] = true @adj[v].each do |u| w = @match[u] if w.nil? || (@visited[w].nil? && dfs(w)) rop,@match[v],@match[u] = true,u,v break end end rop end public def matching #kuhn algorithm: # Start by unsaturated vertex, find an augmenting path, update the matching. r = 0 @match = Array.new(@n) (0...@n).each do |i| unless @match[i] @visited = Array.new(@n) if dfs(i) r+=1 end end end [r,@match] end end class StudentNumber def initialize(*arg) @n,@a, = arg @adj = Array.new(2*@n){Array.new} (0...@n).each do |i| (0...[@a[i],@n].min).each do |j| @adj[i].push(@n+j) @adj[@n+j].push(i) end ([0,@a[i]+1].max...@n).each do |j| @adj[i].push(@n+j) @adj[@n+j].push(i) end end end def ans r,marr = BipartiteMatching.new(2*@n,@adj).matching if marr.any?(nil) [-1] else marr[0,@n].map{_1-@n} end end end ### END: class StudentNumber iod = STDIN n = iod.gets.to_i a = Array.new(n){iod.gets.to_i} puts StudentNumber.new(n,a).ans exit 0