#include using namespace std; const int maxn = 101010; int n, m, k; int c[maxn]; vector> g[maxn]; long dp[4][maxn]; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n >> m >> k; for(int i = 0; i < m; i++) cin >> c[i]; for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--, b--; g[a].push_back({b,c[i]}); g[b].push_back({a,c[i]}); } memset(dp,0x01,sizeof(dp)); dp[0][0] = 0; priority_queue, vector>, greater>> pq; pq.push({0, 0}); while(!pq.empty()) { auto[e,foo] = pq.top(); pq.pop(); int v = foo / 4, t = foo % 4; for(auto[u, cst]: g[v]) { if(t + 1 <= k) { if(dp[t + 1][u] > dp[t][v]) { dp[t + 1][u] = dp[t][v]; pq.push({dp[t + 1][u], u*4+t+1}); } } if(dp[t][u]>dp[t][v]+cst) { dp[t][u]=dp[t][v]+cst; pq.push({dp[t][u],u*4+t}); } } } long ans = 3467192473289423; for(int i = 0; i <= k; i++) ans = min(ans, dp[i][n-1]); if(ans==3467192473289423) ans = -1; cout << ans << "\n"; }