import strutils, sequtils let KN, F = stdin.readLine.split.map(parseInt) var cnt = KN[0] * KN[1] yet: bool for i, A in F: cnt -= A if cnt < 0: yet = true break echo [cnt, -1][yet.int]