#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using ull = unsigned long long; using Graph = vector>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define NP next_permutation const int INF32 = 2e9; const ll INF64 = 2e18; const ll mod = 998244353; // const ll mod = 1e9 + 7; template bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;} void cincout() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } int main() { cincout(); int N, M, K; cin >> N >> M >> K; vector C(M); for (int i = 0; i < M; i++) cin >> C[i]; using P = pair; vector> graph(N); for (int i = 0; i < M; i++) { int u, v; cin >> u >> v; u--, v--; graph[u].emplace_back(v, C[i]); graph[v].emplace_back(u, C[i]); } using A = array; priority_queue, greater> pq; pq.push({0, 0, 0}); vector> dist(N, vector(3, INF64)); dist[0][0] = 0; while (!pq.empty()) { auto [d, v, k] = pq.top(); pq.pop(); if (dist[v][k] < d) continue; for (auto [next_v, w] : graph[v]) { if (chmin(dist[next_v][k], d + w)) pq.push({dist[next_v][k], next_v, k}); if (k < K && chmin(dist[next_v][k + 1], d)) pq.push({dist[next_v][k + 1], next_v, k + 1}); } } ll ans = *min_element(all(dist[N - 1])); cout << (ans != INF64 ? ans : -1) << endl; }