#Lutece0444. Earthquake

Earthquake

Migrated from Lutece 444 Earthquake

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Just a week before,the people in Japan suffered from the heavy earthquake which is estimated to be Richter 9

It brought tremendous impact on the people's security,country's economy and some other aspects.

Admittedly,human beings don't own the ability to take control of the nature,however,if effective treasures are taken,

we can reduce the damage caused by natural disasters to its lowest.

Here,a plan is proposed.That is we want to found stations in cities in order to store enough food,water and some other necessities.

Storing enough resource in a city in advance,we are able to supply this city and other cities adjacent to this one when an earthquake occurs.But founding such a station costs a lot,taking all factors into account.Influenced by the city's location,economy,politics and other factors,founding the station costs differently in different cities.Aiming to use the least money to make sure all cities can be supplied,the controller of the project asking you for help.Note that it's allowed a city can be supplied by different stations.

Input

Multiple test cases ended with EOF

Each test case starts with two integers nn (number of cities,1n100001\leq n\leq 10000) mm (number of relations between two cities,1m100001\leq m\leq 10000)

Next line are nn integers c1,c2,,cnc_1,c_2,\cdots ,c_n (cic_i indicating the cost for building a station in city ii, ci10000c_i\leq 10000)

Following are mm lines,each line includes two integers aa, bb(1a,bn1\leq a,b\leq n , indicating city aa is adjacent to city bb)

Output

A single integer,indicating the minimum cost

Samples

3 2
40 10 20
1 2
1 3
7 5
100 23 41 19 15 20 1
1 2
1 3
1 4
5 6
5 7
30
98

Note

Pay attention! It's assured that no circles exist.

Resources

5th BUPT Programming Contest Final