let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  Scanf.scanf "%d\n" @@ fun q ->
  let brr = Array.init q @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun b c -> (b, c) in
  for i = 0 to q - 1 do
    let (b, c) = brr.(i) in
    let _ = Array.mapi (fun i a -> if a = b then arr.(i) <- c else arr.(i) <- a) arr in
    Printf.printf "%d\n" (Array.fold_left (+) 0 arr)
  done;