On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.

The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.

Help the child to find out, what is the minimum total energy he should spend to remove all n parts.

Input

The first line contains two integers n and m (1 ≤ n ≤ 1000; 0 ≤ m ≤ 2000). The second line contains n integers: v1, v2, ..., vn (0 ≤ vi ≤ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi (1 ≤ xi, yi ≤ n; xi ≠ yi).

Consider all the parts are numbered from 1 to n.

Output

Output the minimum total energy the child should spend to remove all n parts of the toy.

Examples

Input

4 3
10 20 30 40
1 4
1 2
2 3


Output

40


Input

4 4
100 100 100 100
1 2
2 3
2 4
3 4


Output

400


Input

7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4


Output

160

Note

One of the optimal sequence of actions in the first sample is:

  * First, remove part 3, cost of the action is 20. 
  * Then, remove part 2, cost of the action is 10. 
  * Next, remove part 4, cost of the action is 10. 
  * At last, remove part 1, cost of the action is 0. 



So the total energy the child paid is 20 + 10 + 10 + 0 = 40, which is the minimum.

In the second sample, the child will spend 400 no matter in what order he will remove the parts.
n, m = map(int, raw_input().split())

# note that using a connectivty matrix makes removing nodes faster
conn = [[False]*n for i in range(n)]

vs = map(int, raw_input().split())

for _1 in range(m):
    i,j = map(int, raw_input().split())
    conn[i-1][j-1] = True
    conn[j-1][i-1] = True


def energy(i):
    return sum(vs[node] for node, v in enumerate(conn[i]) if v == True)

removed = [False]*n

def remove(i):
    global conn
    global removed
    for j in range(n):
        conn[i][j] = False
        conn[j][i] = False
    removed[i] = True

"""
global_max_energy = sum(vs)
def best_to_remove():
    global conn
    min_ind = 0
    min_energy = global_max_energy
    for i in range(n):
        if removed[i]:
            continue
        val = energy(i)
        print '*'*50
        print i, val
        if val < min_energy:
            min_energy = val
            min_ind = i
        elif val == min_energy and vs[i] > vs[min_ind]:
            min_energy = val
            min_ind = i
    return min_ind, min_energy


for i in range(n):
    break
    min_ind, min_energy = best_to_remove()
    print min_ind, min_energy
    print '#'*50
    remove(min_ind)
    s += min_energy

degrees = [len([1 for v in conn[i] if v]) for i in range(n)]
deg_val_ind = zip(degrees, [-v for v in vs], range(n))

for deg, val, ind in sorted(deg_val_ind):
    break
    s += energy(ind)
    remove(ind)


for i in range(n):
    break
    energies = [energy(i) for i in range(n)]
    energies_val_ind = zip(energies, [-v for v in vs], range(n))
    sorted_list = sorted(energies_val_ind)
    filtered_list = [trip for trip in sorted_list if not removed[trip[-1]]]
    enrg, val, ind = filtered_list[0]
    print filtered_list
    s += enrg
    remove(ind)



import itertools, copy
for perm in itertools.permutations(range(n)):
    break
    conn_copy = copy.deepcopy(conn)
    s = 0
    for ind in perm:
        s += energy(ind)
        remove(ind)
    conn = conn_copy
    removed = [False]*n
    print s, [i+1 for i in perm]
"""


s = 0

val_ind = zip([-v for v in vs], range(n))
sorted_list = sorted(val_ind)

for val, ind in sorted_list:
    s += energy(ind)
    remove(ind)

print s

