use std::io::{Read,stdin}; fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); let mut tok = buf.split_whitespace(); let mut get = || tok.next().unwrap(); macro_rules! get { ($t:ty) => (get().parse::<$t>().unwrap()); () => (get!(i64)); } // たぶん MST だと思うけど、面倒になった let n = get!(usize); let m = get!(); let k = get!(); let mut graph = vec![vec![]; n]; let mut road = vec![]; let mut total = 0; for _ in 0..m { let a = get!(usize)-1; let b = get!(usize)-1; let c = get!(); graph[a].push((c, b)); graph[b].push((c, a)); road.push((a, b, c)); total += c; } let mut flag = vec![false; n]; for _ in 0..k { let e = get!(usize) - 1; let (a, b, c) = road[e]; total -= c; flag[a] = true; flag[b] = true; } println!("{}", total); }