open Printf
open Scanf

let id x = x

let solve n m =
  let la = List.init m @@ fun _ -> scanf "%d " id in
  let pd = n - List.fold_left (+) 0 la in
  if pd >= 0 then pd else -1

let () =
  scanf "%d %d " solve |> printf "%d\n"
