#include using namespace std; using ll = long long; #define rep(i, a, b) for(int i = a; i < (b); i++) constexpr ll INF = 1'000'000'000'000'000'000; int main(){ // 入力 int n,m,k; cin >> n >> m >> k; vector c(m); rep(i, 0, m) cin >> c[i]; vector>> graph(n); rep(i, 0, m) { int u, v; cin >> u >> v; u--,v--; graph[u].push_back({v, c[i]}); graph[v].push_back({u, c[i]}); } // dist[i][j]: クーポンをi枚使った時の町j+1までの最低料金 vector> dist(k+1, vector(n, INF)); // ダイクストラ法を用いてそれぞれの最低料金を計算していく dist[0][0] = 0; using S = array; // {最低料金, 使ったクーポンの数, 町の番号} priority_queue, greater> pq; pq.push({0, 0, 0}); while(!pq.empty()){ auto [now_cost, coupon, pos] = pq.top(); pq.pop(); if(now_cost != dist[coupon][pos]) continue; for(auto [to, edge_cost]: graph[pos]) { // クーポンを使用しない移動 if(dist[coupon][to] > now_cost + edge_cost) { dist[coupon][to] = now_cost + edge_cost; pq.push({dist[coupon][to], coupon, to}); } // クーポンを使用する移動 if(coupon != k) { if(dist[coupon + 1][to] > now_cost) { dist[coupon + 1][to] = now_cost; pq.push({dist[coupon + 1][to], coupon + 1, to}); } } } } // N にいく方法のうち、料金が最小のものを求める ll ans = INF; rep(i, 0, k+1) { ans = min(ans, dist[i][n-1]); } // 答えの出力 if(ans != INF) cout << ans << endl; else cout << -1 << endl; }