let id x = x

let t = Array.init (Scanf.scanf "%d " id) (fun _ -> Scanf.scanf "%d " id)

let px =
  Array.init (Scanf.scanf "%d " id) (fun _ ->
      Scanf.scanf "%d %d " (fun p x -> (p, x)) )


let sum = Array.fold_left ( + ) 0 t

let () =
  Array.iter (fun (p, x) -> sum - (t.(p - 1) - x) |> Printf.printf "%d\n") px
