#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) #define all(a) (a).begin(),(a).end() const ll INF = 1ll << 60; template bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, M, K; cin >> N >> M >> K; vector C(M); rep(i, 0, M) cin >> C[i]; vector>> G(N); rep(i, 0, M) { int u, v; cin >> u >> v; --u, --v; G[u].push_back({v, i}); G[v].push_back({u, i}); } vector dist(K + 1, vector(N, INF)); priority_queue>, vector>>, greater>>> que; dist[K][0] = 0; que.push({0, {K, 0}}); while (!que.empty()) { ll d = que.top().first; int k = que.top().second.first; int v = que.top().second.second; que.pop(); if (d > dist[k][v]) continue; for (pair e : G[v]) { if (k != 0) { if (chmin(dist[k - 1][e.first], dist[k][v])) { que.push({dist[k - 1][e.first], {k - 1, e.first}}); } } if (chmin(dist[k][e.first], dist[k][v] + C[e.second])) { que.push({dist[k][e.first], {k, e.first}}); } } } ll ans = INF; rep(i, 0, K + 1) ans = min(ans, dist[i][N - 1]); cout << (ans == INF ? -1 : ans) << '\n'; }