let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern
let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let h = read_line () |> split_string |> List.map int_of_string |> Array.of_list
let ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a - 1, b - 1)

let m = Array.make n 0

let () =
  Array.iter (fun (a, b) -> m.(a) <- max m.(a) h.(b); m.(b) <- max h.(a) m.(b)) ab;
  Printf.printf "%d\n" @@ Array.fold_left (+) 0 @@ Array.mapi (fun i v -> if v > m.(i) then 1 else 0) h