You are given a connected undirected graph with nodes and edges. Each node has an associated cost .
A cut of the given graph is obtained by removing some edges in order to split the graph into exactly disjoint connected subgraphs.
If the sum of the costs of the nodes from the first subgraph is and the sum of the costs of the nodes from the second subgraph is , then the cost of the cut is equal to , where denotes the absolute value of .
What is the smallest possible cost of a cut of the given graph?
Input
The first line of input contains a single integer () — the number of nodes and edges of the given graph.
The second line contains integers () — the associated costs of the nodes.
The following lines contain the edges of the graph. Each line contains two integers, and () — the endpoints of an edge.
It is guaranteed that there are no multiple edges and that the given graph is connected.
Output
Output a single integer, the minimum possible cost of a cut.
Example 1
stdin
3
1 7 3
1 2
2 3
3 1
stdout
3
Note
If we delete the edges and , the resulting subgraphs will be and . The cost of this cut is equal to .
Example 2
stdin
5
1 7 3 3 6
3 5
5 4
1 4
4 2
2 5
stdout
2
Example 3
stdin
8
5 7 9 12 13 19 7 16
1 2
2 3
3 1
1 4
4 5
4 6
3 7
7 8
stdout
0