Marisa has recently found a treasure map that leads her to an underground cave system consisting of $n$ rooms and $m$ one-way tunnels.
The cave is so dark that Marisa needs to use her power to light it up. If she lights up a room $i$, room $j$ can receive the light if $j$ can be reached from $i$ and $i$ can also be reached in $j$.
The cost of lighting up room $i$ is $A_i$ power. What is the minimum amount of power needed to completely eliminate the darkness in the cave?
### Input
- The first line contains 2 integers $n,m$.
- The second line contains $n$ integers $A_i$.
- The next $m$ lines, each line contains two integers $u, v$, there is a tunnel between $u$ and $v$.
### Output
- Print the minimum amount of power.
### Constraints
- $1 \le n,m \le 10^5$.
- $1 \le A_i \le 10^9$.
- $1 \le u,v \le n$.
### Example
Input:
```
3 3
1 2 3
1 2
2 3
3 1
```
Output:
```
1
```