## https://yukicoder.me/problems/no/3111 import heapq MAX_INT = 10 ** 18 def main(): N, M, K = map(int, input().split()) C = list(map(int, input().split())) next_nodes = [[] for _ in range(N)] for i in range(M): u, v = map(int, input().split()) next_nodes[u -1 ].append((v - 1, C[i])) next_nodes[v - 1].append((u - 1, C[i])) queue = [] seen = [[MAX_INT] * N for _ in range(K + 1)] fix = [[MAX_INT] * N for _ in range(K + 1)] seen[0][0] = 0 heapq.heappush(queue, (0, 0, 0)) while len(queue) > 0: cost, count, v = heapq.heappop(queue) if fix[count][v] < MAX_INT: continue fix[count][v] = cost for w, c in next_nodes[v]: if count + 1 <= K: if fix[count + 1][w] == MAX_INT: new_cost = cost if seen[count + 1][w] > new_cost: seen[count + 1][w] = new_cost heapq.heappush(queue, (new_cost, count + 1, w)) if fix[count][w] < MAX_INT: continue new_cost = cost + c if seen[count][w] > new_cost: seen[count][w] = new_cost heapq.heappush(queue, (new_cost, count, w)) x = MAX_INT for c in range(K + 1): x = min(x, fix[c][N - 1]) if x == MAX_INT: print(-1) else: print(x) if __name__ == "__main__": main()