In this age of rising gas prices, Lyssa has decided to be more conscientious about the routes she takes when driving around. However, her goal isn't to use as little gas as possible; it is to minimize her total spending on gas money. She will go to great lengths in order to secure a great deal on gas.

In her home, Lyssa has a map of all nearby gas stations, the price they sell gas at, and the roads that connect them. When she needs to drive somewhere, she begins her journey on an empty fuel tank at the gas station right beside her house. She then picks out a route that will minimize the amount of money she will spend on gas.

Lyssa has added a large fuel tank to her car so that her car can hold as much gas as she wants. Her car is able to drive one kilometre on one litre of fuel (the huge tank makes her car quite a gas guzzler). Can you figure out the minimum amount of money Lyssa needs to spend on her trip?

#### Input

Each test case begins with integers , the number of gas stations near Lyssa's house and the number of roads connecting them, respectively.

The next line contains integers , which denote the price per litre at the gas station.

The next lines each contain three integers which describe a road kilometres long between gas stations and .

Gas stations are numbers from to . Lyssa begins her journey at gas station and wishes to travel to gas station .

#### Output

For each test case, output the minimum amount that Lyssa needs to spend on gas.

#### Sample Input

```
3 3
10 1 5
1 2 5
1 3 6
2 3 9
```

#### Sample Output

`59`

#### Sample Input

```
5 4
5 4 3 2 1
1 2 1
2 3 1
3 4 1
4 5 1
```

#### Sample Output

`14`

#### Explanation for Sample Input

In the first case, Lyssa first buys 5 litres of gas at the first station, costing her $50. She then travels to the second station, buying 9 litres of gas there, costing her $9. She then uses that gas to travel to the third station. In the second case, Lyssa buys one litre of gas at each station she visits, for a total of .

## Comments