#include using namespace std; constexpr long long INF = 1e18; struct Edge{ int to; long long cost; Edge(int to, long long cost):to(to), cost(cost) {} }; void dijkstra(int start, vector &dist, const vector> &Es){ int N = Es.size(); dist.assign(N, INF); dist[start] = 0; priority_queue, vector>, greater>> pq; pq.push(make_pair(0LL, start)); while (not pq.empty()){ auto dv = pq.top(); pq.pop(); if (dv.first > dist[dv.second]) continue; dist[dv.second] = dv.first; for (auto &uc : Es[dv.second]){ long long new_d = dv.first + uc.cost; if (new_d < dist[uc.to]){ dist[uc.to] = new_d; pq.push(make_pair(new_d, uc.to)); } } } } int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, M, L; cin >> N >> M >> L; vector Ts(N, 0); for (auto & t : Ts) cin >> t; vector> Es(N, vector()); for (int i = 0; i < M; ++i){ int a, b; long long c; cin >> a >> b >> c; Es[a - 1].push_back({b - 1, c}); Es[b - 1].push_back({a - 1, c}); } vector> dist(N, vector()); for (int v = 0; v < N; ++v) dijkstra(v, dist[v], Es); long long ans = INF; for (int g = 0; g < N; ++g){ long long len = 0LL; for (int i = 0; i < N; ++i) len += dist[g][i] * 2 * Ts[i]; long long dif = 0; for (int j = 0; j < N; ++j) { if (Ts[j] >= 1){ dif = min(dif, dist[L - 1][j] - dist[j][g]); } } ans = min(ans, len + dif); } cout << ans << endl; return 0; }