program tyvj1609;
type node=record
y,next,w:longint;
end;
var
n,m,u,v,time,i,tot,x,y,z,max:longint;
a,f,p,q,dist:array[1..10000]of longint;
flag:array[1..10000]of boolean;
g:array[1..100000]of node;
procedure up(l:longint);
var x,xp:longint;
begin x:=dist[p[l]];
xp:=p[l];
while l div 2>=1 do
begin
if dist[p[l div 2 ]]>x then
begin
p[l]:=p[l div 2];
q[p[l]]:=l;
l:=l div 2;
end
else break;
end;
p[l]:=xp;
q[p[l]]:=l;
end;
procedure down(l,n:longint);
var
j,x,xp:longint;
begin j:=l*2;
x:=dist[p[l]];
xp:=p[l];
while j<=n do
begin
if (dist[p[j]]>dist[p[j+1]]) and (j<n) then inc(j);
if dist[p[j]]<x then
begin
p[l]:=p[j];
q[p[l]]:=l;
l:=j;
j:=j*2;
end
else break;
end;
p[l]:=xp;
q[p[l]]:=l;
end;
function dijkstra(x:longint):boolean;
var
j,t,m,k:longint;
begin
for j:=1 to n do
dist[j]:=maxlongint;
dist[u]:=0;
fillchar(q,sizeof(q),0);
fillchar(p,sizeof(p),0);
fillchar(flag,sizeof(flag),0);
m:=0;
t:=f[u];
flag[u]:=true;
while t<>0 do
begin
if a[g[t].y]<=x then
begin
dist[g[t].y]:=g[t].w;
inc(m);
p[m]:=g[t].y;
q[p[m]]:=m;
end;
t:=g[t].next;
end;
for j:=m div 2 downto 1 do
down(j,m);
while m>0 do
begin
k:=p[1];
flag[k]:=true;
p[1]:=p[m];
q[p[1]]:=1;
dec(m);
down(1,m);
t:=f[k];
while t<>0 do
begin
if a[g[t].y]<=x then
begin
if (dist[g[t].y]>dist[k]+g[t].w) and (not flag[g[t].y]) then
begin
dist[g[t].y]:=dist[k]+g[t].w;
if q[g[t].y]=0 then
begin
inc(m);
p[m]:=g[t].y;
q[p[m]]:=m;
end;
up(q[g[t].y]);
end;
end;
t:=g[t].next;
end;
end;
if dist[v]<=time then
exit(true)
else exit(false);
end;
procedure dichotomy(l,r:longint);
var
m:longint;
begin
while l<r do
begin
m:=l+(r-l) div 2;
if dijkstra(m) then
begin
r:=m;
end
else
l:=m+1;
end;
if dijkstra(l) then
writeln(l)
else
writeln(-1);
end;
begin
assign(input,'1609.in');reset(input);
assign(output,'1609.out');rewrite(output);
readln(n,m,u,v,time);
tot:=0;
max:=0;
for i:=1 to n do
begin
read(a[i]);
if a[i]>max then
max:=a[i];
end;
for i:=1 to m do
begin
read(x,y,z);
inc(tot);
g[tot].y:=y;
g[tot].w:=z;
g[tot].next:=f[x];
f[x]:=tot;
inc(tot);
g[tot].y:=x;
g[tot].w:=z;
g[tot].next:=f[y];
f[y]:=tot;
end;
dichotomy(a[u],max+1);
close(input);close(output);
end.
type node=record
y,next,w:longint;
end;
var
n,m,u,v,time,i,tot,x,y,z,max:longint;
a,f,p,q,dist:array[1..10000]of longint;
flag:array[1..10000]of boolean;
g:array[1..100000]of node;
procedure up(l:longint);
var x,xp:longint;
begin x:=dist[p[l]];
xp:=p[l];
while l div 2>=1 do
begin
if dist[p[l div 2 ]]>x then
begin
p[l]:=p[l div 2];
q[p[l]]:=l;
l:=l div 2;
end
else break;
end;
p[l]:=xp;
q[p[l]]:=l;
end;
procedure down(l,n:longint);
var
j,x,xp:longint;
begin j:=l*2;
x:=dist[p[l]];
xp:=p[l];
while j<=n do
begin
if (dist[p[j]]>dist[p[j+1]]) and (j<n) then inc(j);
if dist[p[j]]<x then
begin
p[l]:=p[j];
q[p[l]]:=l;
l:=j;
j:=j*2;
end
else break;
end;
p[l]:=xp;
q[p[l]]:=l;
end;
function dijkstra(x:longint):boolean;
var
j,t,m,k:longint;
begin
for j:=1 to n do
dist[j]:=maxlongint;
dist[u]:=0;
fillchar(q,sizeof(q),0);
fillchar(p,sizeof(p),0);
fillchar(flag,sizeof(flag),0);
m:=0;
t:=f[u];
flag[u]:=true;
while t<>0 do
begin
if a[g[t].y]<=x then
begin
dist[g[t].y]:=g[t].w;
inc(m);
p[m]:=g[t].y;
q[p[m]]:=m;
end;
t:=g[t].next;
end;
for j:=m div 2 downto 1 do
down(j,m);
while m>0 do
begin
k:=p[1];
flag[k]:=true;
p[1]:=p[m];
q[p[1]]:=1;
dec(m);
down(1,m);
t:=f[k];
while t<>0 do
begin
if a[g[t].y]<=x then
begin
if (dist[g[t].y]>dist[k]+g[t].w) and (not flag[g[t].y]) then
begin
dist[g[t].y]:=dist[k]+g[t].w;
if q[g[t].y]=0 then
begin
inc(m);
p[m]:=g[t].y;
q[p[m]]:=m;
end;
up(q[g[t].y]);
end;
end;
t:=g[t].next;
end;
end;
if dist[v]<=time then
exit(true)
else exit(false);
end;
procedure dichotomy(l,r:longint);
var
m:longint;
begin
while l<r do
begin
m:=l+(r-l) div 2;
if dijkstra(m) then
begin
r:=m;
end
else
l:=m+1;
end;
if dijkstra(l) then
writeln(l)
else
writeln(-1);
end;
begin
assign(input,'1609.in');reset(input);
assign(output,'1609.out');rewrite(output);
readln(n,m,u,v,time);
tot:=0;
max:=0;
for i:=1 to n do
begin
read(a[i]);
if a[i]>max then
max:=a[i];
end;
for i:=1 to m do
begin
read(x,y,z);
inc(tot);
g[tot].y:=y;
g[tot].w:=z;
g[tot].next:=f[x];
f[x]:=tot;
inc(tot);
g[tot].y:=x;
g[tot].w:=z;
g[tot].next:=f[y];
f[y]:=tot;
end;
dichotomy(a[u],max+1);
close(input);close(output);
end.