from typing import List, Tuple, Optional import sys import itertools import heapq import bisect from collections import deque, defaultdict from functools import lru_cache, cmp_to_key input = sys.stdin.readline # for AtCoder Easy test if __file__ != 'prog.py': sys.setrecursionlimit(10 ** 6) def readints(): return map(int, input().split()) def readlist(): return list(readints()) def readstr(): return input().rstrip() class Dijkstra: def __init__(self, N: int, E: List[List[Tuple[int, int]]], start: int = 0, inf: int = 1 << 50): self.N = N self.E = E self.start = start self.inf = inf self.C = [self.inf] * N self.prev = [None] * N self._calculate() def get_cost(self, i: int) -> int: """return cost to i-th vertex. return inf if the vertex is unreachable.""" return self.C[i] def get_path(self, i) -> Optional[List[int]]: """return shortest path to i-th vertex if reachable otherwise None""" if not self.reachable(i): return None p = [] cur = i while cur is not None: p.append(cur) cur = self.prev[cur] p.reverse() return p def reachable(self, i) -> bool: """return whether i-th vertex is reachable from start""" return self.C[i] < self.inf def _calculate(self) -> None: h = [(0, self.start)] self.C[self.start] = 0 visited = [False] * self.N while h: _, v = heapq.heappop(h) if visited[v] is True: continue visited[v] = True for c, d in self.E[v]: if self.C[d] > self.C[v] + c: self.C[d] = self.C[v] + c self.prev[d] = v heapq.heappush(h, (self.C[d], d)) N, M, K = readints() R = set(map(lambda x: int(x) - 1, input().split())) E = [[] for _ in range(N)] v = [] path = [] for i in range(M): a, b, c = readints() a -= 1 b -= 1 E[a].append((c, b)) E[b].append((c, a)) if i in R: v.append(a) v.append(b) path.append((a, b, c)) V = sorted(set(v)) idx = {} for i, a in enumerate(V): idx[a] = i path = [(idx[a], idx[b], c) for a, b, c in path] C = [[0 for _ in range(len(V))] for _ in range(len(V))] for i in range(len(V)): solver = Dijkstra(N, E, start=V[i]) for j in range(i + 1, len(V)): c = solver.get_cost(V[j]) C[i][j] = c C[j][i] = c C0 = [] solver = Dijkstra(N, E, start=0) for v in V: C0.append(solver.get_cost(v)) CN = [] solver = Dijkstra(N, E, start=N - 1) for v in V: CN.append(solver.get_cost(v)) INF = 1 << 50 dp = [[INF for _ in range(len(V))] for _ in range(1 << K)] for i in range(len(V)): dp[0][i] = C0[i] for s in range(1 << K): for j in range(K): a, b, c = path[j] if s & (1 << j): continue for k in range(len(V)): nxt = s | (1 << j) dp[nxt][a] = min(dp[nxt][a], dp[s][k] + C[k][b] + c) dp[nxt][b] = min(dp[nxt][b], dp[s][k] + C[k][a] + c) ans = INF for k in range(len(V)): ans = min(ans, dp[-1][k] + CN[k]) print(ans)