Godzilla

No attempts yetTime limit1sMemory limit128 MB

Problem

The dreaded monster Godzilla has decided to visit Byteburg again. Every day the monster crawls out of the ocean, reaches one of the city's skyscrapers, and eats it together with everyone living inside. Eating one skyscraper takes Godzilla an entire day; afterwards it slips back into the sea. While moving across the city, Godzilla's tail accidentally destroys every skyscraper it passes along the way.

The citizens of Byteburg can hardly stand this. That is why, every night, one citizen flees to the countryside from each skyscraper that is still standing.

Every junction in Byteburg holds exactly one skyscraper, and the junctions are joined by two-way streets. One junction sits right next to the ocean; this is where Godzilla begins its journey each day. Godzilla always travels along streets.

Godzilla must hurry, choosing both the skyscrapers to eat and the streets to travel with great care. It cannot eat a skyscraper that has already been eaten or destroyed along the way. What is the maximum number of people Godzilla can eat before the city becomes completely deserted?

Input

The first line contains two integers nn and mm (1n1000001 \le n \le 100\,000, 0m5000000 \le m \le 500\,000), the number of junctions and the number of streets. The junctions are numbered 11 through nn, and junction 11 is the one next to the ocean. The second line contains nn integers kik_i (0ki1000000 \le k_i \le 100\,000), where kik_i is the number of people living in the skyscraper at junction ii. Each of the next mm lines contains two integers aia_i and bib_i (1ai,bin1 \le a_i, b_i \le n, aibia_i \ne b_i), meaning there is a street connecting junctions aia_i and bib_i. Every junction is reachable from junction 11.

Output

Print, on a single line, the number of people Godzilla eats when it chooses which skyscrapers to eat and how to move optimally.