/** author: shobonvip created: 2025.04.19 23:03:50 **/ #include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) #define all(v) v.begin(), v.end() template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; vector c(m); rep(i,0,m) { cin >> c[i]; } vector ikeru(n, vector>(0)); rep(i,0,m) { int u, v; cin >> u >> v; u--; v--; ikeru[u].push_back(pair(v, c[i])); ikeru[v].push_back(pair(u, c[i])); } vector d(k+1, vector(n, 1e18)); d[k][0] = 0; priority_queue> pq; pq.push(make_tuple(0, k, 0)); while(!pq.empty()){ auto [tmp, nk, i] = pq.top(); pq.pop(); tmp = - tmp; if (tmp > d[nk][i]) continue; for (auto [j, w]: ikeru[i]) { ll cost = tmp + w; if (chmin(d[nk][j], cost)) { pq.push(make_tuple(- cost, nk, j)); } } if (nk > 0) { for (auto [j, w]: ikeru[i]) { ll cost = tmp; if (chmin(d[nk-1][j], cost)) { pq.push(make_tuple(- cost, nk-1, j)); } } } } ll ans = 1e18; rep(i,0,k+1) { chmin(ans, d[i][n-1]); } if (ans > 1e17) { cout << -1 << '\n'; }else { cout << ans << '\n'; } }