package Yukicoder /** * Created by hichikawa on 2015/11/02. */ fun main(args: Array) { fun readLineIntArray() : List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toInt() } return ret } val inputBeans = readLineIntArray() var numBeans = inputBeans[0] * inputBeans[1] val personsFimillyAge = readLineIntArray() for (num in personsFimillyAge) { numBeans -= num if (numBeans < 0) { println(-1) return } } println(numBeans) }