from queue import PriorityQueue N,M,K = list(map(int, input().split(' '))) streets = [] for _ in range(N): streets.append([]) total_cost = 0 costs = [0 for _ in range(M)] for i in range(M): a, b, c = list(map(int, input().split(' '))) streets[a-1].append((i,b-1,c)) streets[b-1].append((i,a-1,c)) costs[i] = c total_cost = total_cost + c kept = [] for _ in range(K): e = int(input()) kept.append(e-1) included = [0 for _ in range(M)] key = [float('inf') for _ in range(N)] parent = [-1 for _ in range(N)] mst = [0 for _ in range(N)] que = PriorityQueue() que.put((0,0)) key[0] = 0 while not que.empty(): _,country_a = que.get() mst[country_a] = 1 for street in streets[country_a]: i, country_b, cost = street if mst[country_b] == 0 and cost < key[country_b]: key[country_b] = cost que.put((key[country_b],country_b)) parent[country_b] = country_a for i in range(1,N): for street in streets[i]: if street[1] == parent[i]: included[street[0]] = 1 cost = 0 for i in range(M): if included[i] == 1: cost = cost + costs[i] for i in kept: included[i] = 1 minimum_cost = 0 for i in range(M): if included[i] == 1: minimum_cost = minimum_cost + costs[i] print(total_cost - minimum_cost)