Divers

No attempts yetTime limit1sMemory limit128 MB

Problem

A group of divers is exploring a cave. To get out, every diver has to swim under a large rock, and swimming under the rock requires the single electric torch they all share. The passage under the rock is narrow, so at most two divers can swim under it at the same time.

The divers leave the cave by repeating this pattern until everyone is out:

  • Two divers swim under the rock together, carrying the torch.
  • Then one of those same two divers swims back under the rock with the torch, so the next divers can use it. (After the final crossing nobody has to swim back.)

Each diver swims at a constant pace. When two divers swim together they move at the pace of the slower one, so a crossing by two divers takes the larger of their two times. A single diver swimming back takes that diver's own time.

Some pairs of divers dislike each other and refuse to swim under the rock together, so such a pair can never cross as a couple.

Find the shortest total time in which all divers can get out of the cave, or report that it is impossible.

Input

The first line contains two integers nn and mm (2n1000002 \le n \le 100000, 0mmin(100000, n(n1)/2)0 \le m \le \min(100000,\ n(n-1)/2)): the number of divers and the number of disliking pairs.

The second line contains nn space-separated integers t1,t2,,tnt_1, t_2, \ldots, t_n (1ti5000000001 \le t_i \le 500000000), where tit_i is the time diver ii needs to swim under the rock.

Each of the next mm lines contains two integers aa and bb (1a,bn1 \le a, b \le n, aba \ne b): a pair of divers who dislike each other and will not swim under the rock together. Each unordered pair {a,b}\{a, b\} appears at most once.

Output

Print a single integer: the shortest total time in which all divers can get out of the cave. If it is impossible for all of them to get out under these rules, print the word IMPOSSIBLE instead.