#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; templateusing V=vector; templateusing VV=V>;//B(n,V(n)) const ll INF=1e18; struct Edge{ int to; ll w; Edge(int to,ll w):to(to),w(w){} }; using Graph=VV; using pli=pair; template bool chmin(T& a,T b){ return ((a>b)?(a=b,true):(false)); } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,m,k; cin>>n>>m>>k; V C(m); rep(i,m) cin>>C[i]; Graph G(n*(k+1)); rep(i,m){ int a,b; cin>>a>>b; a--,b--; rep(j,k+1){ G[a+n*j].push_back(Edge(b+n*j,C[i])); G[b+n*j].push_back(Edge(a+n*j,C[i])); } rep(j,k){ G[a+n*j].push_back(Edge(b+n*(j+1),0)); G[b+n*j].push_back(Edge(a+n*(j+1),0)); } } V dist(n*(k+1),INF); int s=0; dist[s]=0; priority_queue,greater> que; que.push({dist[s],s}); while(!que.empty()){ int v=que.top().second; ll d=que.top().first; que.pop(); if(d>dist[v]) continue; for(auto e:G[v]){ if(chmin(dist[e.to],dist[v]+e.w)){ que.push({dist[e.to],e.to}); } } } ll ans=INF; rep(j,k+1) ans=min(ans,dist[n-1+n*j]); if(ans==INF) cout<<-1<