PA2009 Cakes

题目描述

N个点m条边，每个点有一个点权a。

N<100000，，m<250000。

输入格式

The first line of the standard input contains two integers  n and m (1<=N<=100000,1<=M<=250000) separated by a single space and denoting the number of confectioners at the convention and the number of pairs of them that like each other. The participants of the convention are numbered from  1 to N, The second line contains n integers pi (1<=Pi<=1000000) separated by single spaces and denoting the requirements of respective confectioners for flour (in decagrams). The following m lines contain data about pairs of contestants that like each other. Each of these lines contains two integers ai and bi (1<=ai,bi<=n Ai<>Bi) separated by a single space. They denote that confectioners ai and bi like each other. We assume that all pairs of participants of the convention apart from the ones listed in the input would not like to bake cakes together. Each pair of confectioners appears at most once in the input.

输出格式

The first and only line of the standard output should contain a single integer - the quantity of flour that will be used by all teams in total, in decagrams.

5 7
1 5 3 4 2
1 2
2 3
5 2
4 3
3 1
1 4
5 1

样例输出

14
Explanation of the example. The following three-person teams: (1,2,3),(1,2,5) and (1,3,4)require 5, 5 and 4 decagrams of flour to bake the cakes. In total 5+5+4=14 decagrams of flour are required.