import sys from operator import itemgetter from collections import defaultdict, deque import heapq import bisect from itertools import combinations, product stdin=sys.stdin sys.setrecursionlimit(10 ** 8) ip=lambda: int(sp()) fp=lambda: float(sp()) lp=lambda:list(map(int,stdin.readline().split())) sp=lambda:stdin.readline().rstrip() Yp=lambda:print('Yes') Np=lambda:print('No') inf = float('inf') eps = 1e-9 sortkey = itemgetter(0) from collections import Counter class union_find(): def __init__(self,n): self.n=n ##親要素のノード番号を格納。par[x]==xのときそのノードは根 ##親とはその上にノードなし!!  self.par=[-1 for i in range(n)] self.rank=[0]*(n) def find(self,x): if self.par[x]<0: return x else: self.par[x]=self.find(self.par[x]) return self.par[x] def union(self,x,y): x=self.find(x) y=self.find(y) ##木の高さを比較し、低い方から高い方へ辺をはる if x==y: return if self.par[x]>self.par[y]: x,y=y,x self.par[x]+=self.par[y] self.par[y]=x ##2つが同じ親かどうか def same(self,x,y): return self.find(x) == self.find(y) ##所属のサイズ def size(self,x): return -self.par[self.find(x)] ##同じ親のものを表示 def members(self,x): root=self.find(x) return [i for i in range(self.n) if self.find(i)==root] ##親を表示!! def roots(self): return [i for i, x in enumerate(self.par) if x<0] def all_group_member(self): return {r:self.members(r) for r in self.roots()} def group_count(self): return len(self.roots()) ## uf memo ## 素集合に分けるが、各集合には親というIDが振られているという意識を持つ!!(ABC049_Dより) ############################################################### N, M, K = lp() A = lp() edges = [[inf for _ in range(N)] for _ in range(N)] for i in range(N): edges[i][i] = 0 for _ in range(M): x, y, z = lp() x -= 1; y -= 1 edges[x][y] = z edges[y][x] = z for mid in range(N): for s in range(N): for g in range(N): dist = min(edges[s][g], edges[s][mid] + edges[mid][g]) edges[s][g] = dist adj = [[edges[i][j], i, j]for i, j in product(range(N), repeat=2) if i < j] adj.sort(key=lambda x:x[0]) citys = [i for i in range(N)] ans = inf for v in combinations(citys,K): uf = union_find(N) temp = 0 candidate = [0 for _ in range(N)] cnt = 0 for city in v: temp += A[city] candidate[city] = 1 if cnt == K - 1: ans = min(ans, temp) continue for cost, x, y in adj: if candidate[x] == 1 and candidate[y] == 1 and not uf.same(x, y): uf.union(x, y) temp += cost cnt += 1 if cnt == K - 1: ans = min(ans, temp) break print(ans)