Foody Uncle Mike


Uncle Mike goes on various food adventures from town to town. Today he finds himself in food-topia, a land containing only restaurants, which are connected by bi-directional roads.

Uncle Mike wishes to visit a restaurant tt, but there are just so many temptations along the way - how could he resist the aroma of food waffing through the air! Everytime Mike passes by a restaurant, he must simply try it! But at the same time, he does not want to arrive at his destination too late and it is closed. Help uncle Mike find his way to restaurant tt as quickly as possible!

Input

The first line contains nn, kk - the number of restaurants, and the number of direct paths between two restaurants.

The next line contains ss, tt that is the restaurant uncle Mike first started at, and the restaurant uncle Mike wants to get to.

The third line contains nn numbers that is the eating time xx at each restaurant.

The next kk lines contains two restaurants u,vu, v and the time dd taken to go between them.

Output

Print a single number, that is the minimum amount of time needed for uncle Mike to arrive at restaurant tt.

Constraints

  • 2n1002 \leq n \leq 100
  • 1k100001 \leq k \leq 10000
  • 1u,v,s,tn1 \leq u,v,s,t \leq n
  • 1x,d1001 \leq x, d \leq 100
  • sts \neq t
  • It is guaranteed that there is at most one direct path between any two restaurants.
  • It is guaranteed that there always exist a valid path between ss and tt.

Example 1

Input 1
5 4
1 5
1 2 3 4 5
1 2 1
1 3 2
4 2 3
5 4 7
Output 1
18
Explanation

The restaurants and their connecting roads are depicted in the diagram below.

Mike starts at restaurant 11, and wants to travel to restaurant 55. In order to do so, he must spend 1111 units of time travelling on the road, and 1+2+4=71 + 2 + 4 = 7 units of time eating at restaurants 11, 22 and 44 along the way.

Example 2

Input 2
6 9
3 4
2 17 8 6 9 3
1 2 6
1 3 10
1 4 21
2 3 5
2 5 7 
3 6 11
4 5 31
4 6 4
5 6 28
Output 2
26
Explanation

The restaurants and their connecting roads are depicted in the diagram below.

Mike starts at restaurant 33, and wants to travel to restaurant 44. In order to do so, he can travel through vertex 66. This takes 1515 units of time on the road, and 1111 units of time eating at restaurants 33 and 66.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.