import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let nm = readInts()
    var n = nm[0]
    let a = readInts()
    
    for i in 0..<a.count {
        n -= a[i]
        if 0 > n {
            print(-1)
            return
        }
    }
    print(n)
}

main()
