시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 256 MB 4 4 4 100.000%

## 문제

You are given a forest with $N$ vertices and $M$ edges. The vertices are numbered $0$ through $N-1$. The edges are given in the format $(x_i,y_i)$, which means that vertex $x_i$ and $y_i$ are connected by an edge.

Each vertex $i$ is assigned value $a_i$. You want to add edges in the given forest so that the forest becomes connected. To add an edge, you choose two different vertices $i$ and $j$, then span an edge between $i$ and $j$. This operation costs $a_i + a_j$ dollars, and afterward neither vertex $i$ nor $j$ can be selected again.

Find the minimum total cost required to make the forest connected, or print "Impossible" if it is impossible.

## 입력

Input is given in the following format:

$N$ $M$

$a_0$ $a_1$ $\ldots$ $a_{N-1}$

$x_1$ $y_1$

$\ldots$

$x_M$ $y_M$

## 출력

Print the minimum total cost required to make the forest connected, or print "Impossible" if it is impossible.

## 제한

$1 \le N \le 100\,000$, $0 \le M \le N-1$, $1 \le a_i \le 10^9$, $0 \le x_i,y_i \le N-1$. The given graph is a forest. All input values are integers.

## 예제 입력 1

7 5
1 2 3 4 5 6 7
3 0
4 0
1 2
1 3
5 6


## 예제 출력 1

7


## 예제 입력 2

5 0
3 1 4 1 5


## 예제 출력 2

Impossible


## 예제 입력 3

1 0
5


## 예제 출력 3

0


## 힌트

In Sample 1, if we connect vertices $0$ and $5$, the graph become connected, and the cost is $1 + 6 = 7$.

In Sample 2, we can't make the graph connected.

In Sample 3, the graph is connected, regardless of whether we do something or not.