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 v_{i}. The child spend v_{f}_1 + v_{f}_2 + ... + v_{f}_{k} energy for removing part i where f_1, f_2, ..., f_{k} 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: v_1, v_2, ..., v_{n} (0 ≤ v_{i} ≤ 10^5). Then followed m lines, each line contains two integers x_{i} and y_{i}, representing a rope from part x_{i} to part y_{i} (1 ≤ x_{i}, y_{i} ≤ n; x_{i} ≠ y_{i}).

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.

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Round 250 Div 2 Problem C

Author  : chaotic_iak
Language: Python 3.3.4
"""

class IOHandlerObject(object):
    def getInput(self, mode=2):
        # 0: String
        # 1: List of strings
        # 2: List of integers
        inputs = input().strip()
        if mode == 0:
            return inputs
        if mode == 1:
            return inputs.split()
        if mode == 2:
            return [int(x) for x in inputs.split()]

    def writeOutput(self, s="\n"):
        if isinstance(s, list): s = " ".join(s)
        print(s)

IOHandler = IOHandlerObject()
g = IOHandler.getInput
w = IOHandler.writeOutput

############################## SOLUTION ##############################
n,m = g()
v = g()
sm = 0
for i in range(m):
    x,y = g()
    sm += min(v[x-1], v[y-1])
print(sm)

#! /usr/bin/env python

n, m = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
sv = [(x + 1, v[x]) for x in range(n)]
v = [0] + v
edges = {i:set() for i in range(1, n+1)}
for i in range(m):
    f, t = [int(x) for x in input().split()]
    edges[f].add(t)
    edges[t].add(f)

ans = 0
sv.sort(key=lambda x: -x[1])
removed = [False] * (n + 1)
for i, vi in sv:
    removed[i] = True
    for f in edges[i]:
        if not removed[f]:
            ans += v[f]

print(ans)


n, m = map(int, input().split())
v1 = list(map(int, input().split()))
v = [[w, i] for i, w in enumerate(v1)]
v.sort(reverse = True)
d = [set() for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[a].add(b)
    d[b].add(a)
ans = 0
for w, i in v:
    for j in d[i]:
        ans += v1[j]
        d[j].discard(i)
        
print(ans)

n, m = map(int, input().split())
f = [int(x) for x in input().split()]
ans = 0
for i in range(m):
  a, b = map(int, input().split())
  ans += min(f[a - 1], f[b - 1])
print(ans)

def main():
    from heapq import heapify, heappop
    
    n, m = [int(i) for i in input().split()]
    energy = [[int(v), i] for i, v in enumerate(input().split())]
    s_energy = sorted(energy)
    graph = [set() for i in range(n)]
    for i in range(m):
        x, y = [int(i) for i in input().split()]
        graph[x - 1].add(y - 1)
        graph[y - 1].add(x - 1)
    
    result = 0
    for i in range(n):
        e, x = s_energy.pop()
        for j in graph[x]:
            graph[j].remove(x)
            result += energy[j][0]
            
    print(result)
            

main()


n, m = [int(i) for i in input().split()]
energy = [int(i) for i in input().split()]
result = 0
for i in range(m):
    x, y = [int(i) for i in input().split()]
    result += min(energy[x - 1], energy[y - 1])
        
print(result)


(n, m), f, s = list(map(int, input().split())), [int(x) for x in input().split()], 0

for i in range(m):
    (a, b) = list(map(int, input().split()))
    s = s + min(f[a - 1], f[b - 1])

print( s )

n, m = list(map(int, input().split()))
v = list(map(int, input().split()))
graph = [set() for _ in range(n)]
strengths = list()
ans = 0

for i in range(m):
    x, y = list(map(int, input().split()))
    graph[x-1].add(y - 1)
    graph[y-1].add(x - 1)

for i in range(n):
    strengths.append([v[i], i])

strengths = list(reversed(sorted(strengths)))

while len(strengths) > 0:
    (vi, i) = strengths.pop(0)
    ans += sum(v[j] for j in graph[i])
    for s in strengths:
        if i in graph[s[1]]:
            graph[s[1]].remove(i)

print(ans)


n, m = [int(c) for c in input().split()]
v = [0] + [int(c) for c in input().split()]
chains = [[] for _ in range(n + 1)]

for i in range(m):
    a, b = [int(c) for c in input().split()]
    chains[a].append(b)
    chains[b].append(a)

res = 0

for i in range(n):
    m = 0
    ind = 0
    for j in range(len(v)):
        if v[j] > m:
            m = v[j]
            ind = j

    res += sum([v[_] for _ in chains[ind]])

    v[ind] = 0

print(res)

n, m = list(map(int, input().split()))
cs = [0] + list(map(int, input().split()))
mls = [0 for i in range(n+1)]
for i in range(m):
    x, y = list(map(int, input().split()))
    if cs[y] < cs[x]:
        x, y = y, x
    mls[x] += 1
print(sum([cs[i]*mls[i] for i in range(n+1)]))


R = lambda:map(int, input().split())
n, m = R()
v = list(R())
g = [set() for i in range(n + 1)]
for i in range(m):
  x, y = R()
  g[x].add(y)
  g[y].add(x)
s = 0
for w, i in sorted(zip(v, range(1, n + 1)), reverse=True):
  for j in g[i]:
    s += v[j - 1]
    g[j].remove(i)
print(s)

R = lambda:map(int, input().split())
n, m = R()
v = [0] + list(R())
print(sum(min(v[x], v[y]) for x, y in (R() for i in range(m))))

n, m = map(int, input().split())
u = list(map(int, input().split()))
v = list(enumerate(u, 1))
v.sort(key = lambda x: x[1], reverse = True)
s, u = 0, [0] + u
p = [[] for i in range(n + 1)]
for i in range(m):
    x, y = map(int, input().split())
    p[x].append(y)
    p[y].append(x)
for x, f in v:
    for y in p[x]: s += u[y]
    u[x] = 0
print(s)

n, m = map(int, input().split())
r = list(enumerate(map(int, input().split()), 1))
r.sort(key = lambda x: x[1])
s, p = 0, [[] for i in range(n + 1)]
for i in range(m):
    x, y = map(int, input().split())
    p[x].append(y)
    p[y].append(x)
q = [len(t) for t in p]  
for x, f in r:
    s += f * q[x]
    for y in p[x]: q[y] -= 1
print(s)

n, m = map( int, input().split() )
v = list( map( int, input().split() ) )

ans = 0
for i in range( m ):
    x, y = map( int, input().split() )
    ans += min( v[x - 1], v[y - 1] )
    
print( ans )

n, m = map( int, input().split() )
v = [ int( elm ) for elm in input().split() ]
ans = 0
for i in range( m ):
  x, y = map( int, input().split() )
  ans += min( v[x - 1], v[y - 1] )
print( ans )

R = lambda:map(int, input().split())
n, m = R()
v = [0] + list(R())
print(sum(min(v[x], v[y]) for x, y in (R() for i in range(m))))

__author__ = 'asmn'
import sys



n, m = tuple(map(int, input().split()))
v = list(map(int, input().split()))
e = [[] for i in range(n)]
for k in range(m):
    x, y = tuple(map(int, input().split()))
    e[x - 1].append(y - 1)
    e[y - 1].append(x - 1)

nx = sorted(list(range(n)), key=lambda x: v[x], reverse=True)

used = set()
ans = 0
for x in nx:
    for y in e[x]:
        if y not in used:
            ans += v[y]
    used.add(x)
print(ans)



n, m = map(int, input().split())

r = sorted(enumerate(map(int, input().split())), key=lambda x: x[1])
p = [[] for i in range(n)]

for i in range(m):
    x, y = map(lambda n: int(n) - 1, input().split())
    p[x] += [y]
    p[y] += [x]
q = [len(i) for i in p]
s = 0
for x, f in r:
    s += q[x] * f
    for y in p[x]:
        q[y] -= 1

print(s)

n,m = list(map(int,input().split()))
fun = [int(x) for x in input().split()]
ans = 0
for i in range(m):
    a,b=list(map(int,input().split()))
    ans+=min(fun[a-1],fun[b-1])
print (ans)


n, m = map(int, input().split())
v = list(map(int, input().split()))
r = [set() for i in range(n)]
for i in range(m):
    n1, n2 = (int(x) - 1 for x in input().split())
    r[n1].add(n2)
    r[n2].add(n1)
val = 0
for x in reversed(sorted((x, i) for i, x in enumerate(v))):
    for y in r[x[1]]:
        val += v[y]
        r[y].remove(x[1])
print(val)

'''
Created on ٠١‏/٠١‏/٢٠١٥

@author: mohamed265
'''
t = input().split()
n = int(t[0])
m = int(t[1])
slon = 0
num = [int(x) for x in input().split()]
for i in range(m):
    t = input().split()
    slon += min(num[int(t[0])-1] , num[int(t[1])-1])
print(slon)

t = input().split()
n = int(t[0])
m = int(t[1])
slon = 0
num = [int(x) for x in input().split()]
for i in range(m):
    t = input().split()
    slon += min(num[int(t[0])-1] , num[int(t[1])-1])
print(slon)

n, m = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
a = [[] for x in range(n)]
used = [0] * n
for i in range(m):
	x, y = [int(x) for x in input().split()]
	x -= 1
	y -= 1
	a[x].append(y)
	a[y].append(x)
l = sorted(zip(v, list(range(n))), key = lambda x: -x[0])
ans = 0
for _, i in l:
	used[i] = 1
	for x in a[i]:
		if not used[x]:
			ans += v[x]
print(ans)


def main():
    n, m = map(int, input().split())
    vv = list(map(int, input().split()))
    print(sum(min(vv[i - 1] for i in map(int, input().split())) for _ in range(m)))


def __starting_point():
    main()
__starting_point()