#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct boil{
int mass=0;
int len=0;
char n/*new*/='y';//yes
char visit='n';//no
vector <int> link;
vector <int> dis;
};
int main() {
int N,M,B,C;
cin>>N>>M>>B>>C;
boil A[N];
int need;
for(int i=0;i<N;i++){
cin>>A[i].mass;
if(A[i].mass<B)need=i;
}
int a,b,s;
while(cin>>a>>b>>s){
a--;
b--;
A[a].link.push_back(b);
A[a].dis.push_back(s);
A[b].link.push_back(a);
A[b].dis.push_back(s);
}
queue <int> A_tmp;
A_tmp.push(need);
A[need].n='n';
int ans=0;
while(!(A_tmp.empty())){
int u=A_tmp.front();
A_tmp.pop();
A[u].visit='y';
for(int i=0;i<A[u].link.size();i++){
if(A[A[u].link[i]].visit=='n')
A_tmp.push(A[u].link[i]);
if(A[A[u].link[i]].len>A[u].len+A[u].dis[i] || A[A[u].link[i]].n=='y'){
A[A[u].link[i]].len=A[u].len+A[u].dis[i];
A[A[u].link[i]].n='n';
}
}
}
while(A[need].mass<B){
int m=0;
for(int i=0; i<N;i++){
if((A[i].len<A[m].len|| A[m].mass<=B) && i!=need && A[i].mass>B)
m=i;
}
if(A[need].mass+(A[m].mass-B)<=B){
ans+=A[m].len*(A[m].mass-B);
A[need].mass+=A[m].mass-B;
A[m].mass=B;
}
else{
ans+=A[m].len*(B-A[need].mass);
int b=B-A[need].mass;
A[need].mass=B;
A[m].mass-=B-A[need].mass;
}
}
cout<<ans*C;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDx2ZWN0b3I+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3QgYm9pbHsKCWludCBtYXNzPTA7CglpbnQgbGVuPTA7CgljaGFyIG4vKm5ldyovPSd5JzsvL3llcwoJY2hhciB2aXNpdD0nbic7Ly9ubwoJdmVjdG9yIDxpbnQ+IGxpbms7Cgl2ZWN0b3IgPGludD4gZGlzOwp9OwoKaW50IG1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