import sys from collections import defaultdict import numpy as np from scipy.sparse.csgraph import connected_components, minimum_spanning_tree from scipy.sparse import csr_matrix input = sys.stdin.buffer.readline MAX = 10 ** 10 N, M, K = map(int, input().split()) if not M: print(0);exit() ABC = np.array([tuple(map(int, input().split())) for _ in range(M)], dtype=np.int64) ABC[:, :2] -= 1 ans = ABC[:, 2].sum() if K: E = np.array([int(input()) - 1 for _ in range(K)]) frm = ABC[E, 0] to = ABC[E, 1] ans -= ABC[E, 2].sum() connection = csr_matrix(([1] * K, (frm, to)), shape=(N, N)) compress_N, labels = connected_components(connection) ABC[:, :2] = labels[ABC[:, :2]] else: compress_N = N d = defaultdict(lambda: MAX) for a, b, c in ABC: if a == b: continue if a > b: a, b = b, a d[(a, b)] = min(d[(a, b)], c) length, frm, to = [], [], [] for (a, b), c in d.items(): length.append(c) frm.append(a) to.append(b) matr = csr_matrix((length, (frm, to)), shape=(compress_N, compress_N)) T = minimum_spanning_tree(matr) ans -= int(T.sum()) print(ans)