#include using namespace std; long long inf = 1001001001001001001; bool chmin(long long &x,long long y) { if(x > y) { x = y; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,M,C; cin >> N >> M >> C; vectorA(N); long long sum = 0; for(int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } vector>road(N+1); for(int i = 0; i < M; i++) { int L,R; cin >> L >> R; L--; road[L].push_back(R); road[R].push_back(L); } vectordist(N+1,inf); dist[0] = 0; priority_queue,vector>,greater>>que; que.push({0,0}); while(!que.empty()) { auto a = que.top(); que.pop(); if(dist[a.second] != a.first) continue; for(auto i:road[a.second]) { if(chmin(dist[i],a.first+C)) { que.push({dist[i],i}); } } if(a.second < N) { if(chmin(dist[a.second+1],a.first+A[a.second])) { que.push({dist[a.second+1],a.second+1}); } } if(a.second) { if(chmin(dist[a.second-1],a.first+A[a.second-1])) { que.push({dist[a.second-1],a.second-1}); } } } cout << sum-dist[N] << "\n"; }