total = 0 s = gets.chomp.split(" ") s2 = gets.chomp.split(" ") mame = s[0].to_i * s[1].to_i s2.each {|n| total += n.to_i} res = mame - total if res < 0 p -1 else p res end