import sys from itertools import combinations as combi input = sys.stdin.readline N, M, K = map(int, input().split()) a = list(map(int, input().split())) d = [[10 ** 18] * N for _ in range(N)] for i in range(M): u, v, c = map(int, input().split()) d[u - 1][v - 1] = c d[v - 1][u - 1] = c for k in range(N): for i in range(N): for j in range(N): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) import heapq class prim: def __init__(self, n, e): self.e = e self.n = n def MSTcost(self): h = [] visited = [0] * (self.n + 1) ks = range(K) b = pow(10, 10) for edge in self.e[ks[0]]: heapq.heappush(h, edge[1] * b + edge[0]) res = 0 visited[ks[0]] = 1 while len(h): p = heapq.heappop(h) p0 = p // b p1 = p % b if visited[p1]: continue visited[p1] = 1 for q in self.e[p1]: if visited[q[0]]: continue heapq.heappush(h, q[1] * b + q[0]) res += p0 return res res = 10 ** 18 for c in combi(range(N), K): cres = 0 e = [[] for _ in range(K)] for i in range(K): for j in range(K): e[i].append((j, d[c[i]][c[j]])) pri = prim(N, e) cres += pri.MSTcost() for i in c: cres += a[i] res = min(res, cres) #print(c, cres, d) print(res)