#include <bits/stdc++.h>
#include <chrono>

#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define eb emplace_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
  ios::sync_with_stdio(0)

  cin.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  int first = uniform_int_distribution<int>(3123, 32485342)(rng);
  int a = first;
  if ((a & 1) == 1) a++;
  cout << a + n << ' ' << a << '\n';
}


#include <bits/stdc++.h>
#include <chrono>

#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define eb emplace_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first

#define s second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

typedef vector<vi> vvi;

typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  int first = uniform_int_distribution<int>(3123, 32485342)(rng);
  int a = first;
  if ((a & 1) == 1) a++;
  cout << a + n << ' ' << a << '\n';
}


#include <bits/stdc++.h>
#include <chrono>

#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define eb emplace_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first

#define s second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;

typedef vector<i64> vi64;

typedef vector<vi64> vvi64;

typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  int first = uniform_int_distribution<int>(3123, 32485342)(rng);
  int a = first;
  if ((a & 1) == 1) a++;
  cout << a + n << ' ' << a << '\n';
}


#include <bits/stdc++.h>
#include <chrono>

#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define eb emplace_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()

#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  int first = uniform_int_distribution<int>(3123, 32485342)(rng);
  int a = first;
  if ((a & 1) == 1) a++;
  cout << a + n << ' ' << a << '\n';
}


#include <bits/stdc++.h>
#include <chrono>

#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define eb emplace_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first

#define s second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;

typedef vector<vpii> vvpii;
typedef long long i64;

typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;

typedef vector<pi64> vpi64;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  int first = uniform_int_distribution<int>(3123, 32485342)(rng);
  int a = first;
  if ((a & 1) == 1) a++;
  cout << a + n << ' ' << a << '\n';
}


#include <vector>
#include <stdio.h>
#include <string.h>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <unordered_map>

#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int a, n, m, k;
bool visited[200005];
map<int, int>cnt;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 }; int ret;
vector<vector<int > >adjlist;
ll power(ll a, ll b)
{
	if (b == 1)
	{
		return a;
	}
	if (b == 0)
	{
		return 1;
	}
	if (b % 2 == 0)
	{
		return power(a*a, b / 2);
	}
	else
	{
		return a*power(a, (b - 1));
	}
}
long long C(int n, int r)
{
	if (r == 0)
		return 0;
	if (r > n / 2) r = n - r;
	long long ans = 1;
	for (int i = 1; i <= r; i++)
	{
		ans *= n - r + i;
		ans /= i;
	}
	return ans;
}

int main()
{
	std::cin.tie();
	std::ios::sync_with_stdio(false);
	cin >> n >> m; vector<pair<int,int>>cost;
	int a[1001];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int res = 0;
	for (int i = 0; i < m; i++) {
		int e, x; cin >> e >> x;
		res += min(a[e], a[x]);
	}
	cout << res << endl;
	return 0;
}


#include <vector>
#include <stdio.h>
#include <string.h>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <unordered_map>

#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int a, n, m, k;
bool visited[200005];
map<int, int>cnt;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 }; int ret;
vector<vector<int > >adjlist;
ll power(ll a, ll b)
{
	if (b == 1)
	{
		return a;
	}
	if (b == 0)
	{
		return 1;
	}
	if (b % 2 == 0)
	{
		return power(a*a, b / 2);
	}
	else
	{
		return a*power(a, (b - 1));
	}
}
long long C(int n, int r)
{
	if (r == 0)
		return 0;
	if (r > n / 2) r = n - r;
	long long ans = 1;
	for (int i = 1; i <= r; i++)
	{
		ans *= n - r + i;
		ans /= i;
	}
	return ans;
}

int main()
{
	std::cin.tie();
	std::ios::sync_with_stdio(false);
	cin >> n >> m; vector<pair<int,int>>cost;
	adjlist.resize(m + m);
	int a[1002];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cost.push_back({ a[i],i });
	}
	for (int i = 0; i < m; i++)
	{
		int e, b;
		cin >> e >> b;
		adjlist[e].push_back(b);
		adjlist[b].push_back(e);
	}
	sort(cost.rbegin(), cost.rend());
	int res = 0;;
	for (int i = 0; i < n; i++)
	{
		visited[cost[i].second] = 1;
		for (int f = 0; f < adjlist[cost[i].second].size(); f++)
		{
			if (!visited[adjlist[cost[i].second][f]])
			{
				res += a[adjlist[cost[i].second][f] ];
				//visited[adjlist[cost[i].second][f]] = 1;
			}
		}
	}
	cout << res << endl;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define eb            emplace_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vii           vector<pair<ll , ll > >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define fbo            find_by_order
#define ook            order_of_key
//#define cin   abc
//#define cout  qwe
using namespace std;
using namespace __gnu_pbds;
ll n;

int solve()
{
ll m;
cin>>n>>m;
vi v[n+1];
ll a[n+1];
rep(i,1,n+1)
cin>>a[i];
rep(i,0,m)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);

}

ll c=0;
rep(i,1,n+1)
{
    rep(j,0,sz(v[i]))
    {if(a[v[i][j]]<a[i])
        c+=a[v[i][j]];
        else
            if(a[v[i][j]]==a[i])
        {
            c+=a[v[i][j]]/2;

        }
    }

}

cout<<c;

return 0;
}

int main()
{ ios_base::sync_with_stdio(false);
    cin.tie(0);
   cout.tie(0);
        //        ifstream abc("input.txt");
        //        ofstream qwe("output.txt");
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define eb            emplace_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vii           vector<pair<ll , ll > >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define fbo            find_by_order
#define ook            order_of_key
//#define cin   abc
//#define cout  qwe
using namespace std;
using namespace __gnu_pbds;
ll n;

int solve()
{
ll m;
cin>>n>>m;
vi v[n+1];
float a[n+1];
rep(i,1,n+1)
cin>>a[i];
rep(i,0,m)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);

}

float c=0;
rep(i,1,n+1)
{
    rep(j,0,sz(v[i]))
    {if(a[v[i][j]]<a[i])
        c+=a[v[i][j]];
        else
            if(a[v[i][j]]==a[i])
        {
            c+=a[v[i][j]]/2;

        }
    }

}

cout<<c;

return 0;
}

int main()
{ ios_base::sync_with_stdio(false);
    cin.tie(0);
   cout.tie(0);
        //        ifstream abc("input.txt");
        //        ofstream qwe("output.txt");
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define eb            emplace_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vii           vector<pair<ll , ll > >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define fbo            find_by_order
#define ook            order_of_key
//#define cin   abc
//#define cout  qwe
using namespace std;
using namespace __gnu_pbds;
ll n;

int solve()
{
ll m;
cin>>n>>m;
vi v[n+1];
ll a[n+1];
rep(i,1,n+1)
cin>>a[i];
rep(i,0,m)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);

}
ll r=0;
ll c=0;
rep(i,1,n+1)
{
    rep(j,0,sz(v[i]))
    {if(a[v[i][j]]<a[i])
        c+=a[v[i][j]];
        else
            if(a[v[i][j]]==a[i])
        {
            r+=a[v[i][j]];

        }
    }

}

cout<<c+r/2;

return 0;
}

int main()
{ ios_base::sync_with_stdio(false);
    cin.tie(0);
   cout.tie(0);
        //        ifstream abc("input.txt");
        //        ofstream qwe("output.txt");
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define eb            emplace_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vii           vector<pair<ll , ll > >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define fbo            find_by_order
#define ook            order_of_key
//#define cin   abc
//#define cout  qwe
using namespace std;
using namespace __gnu_pbds;
ll n;

int solve()
{
ll m;
cin>>n>>m;
vi v[n+1];
ll a[n+1];
rep(i,1,n+1)
cin>>a[i];
rep(i,0,m)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);

}

float c=0;
rep(i,1,n+1)
{
    rep(j,0,sz(v[i]))
    {if(a[v[i][j]]<a[i])
        c+=a[v[i][j]];
        else
            if(a[v[i][j]]==a[i])
        {
            c+=(float)a[v[i][j]]/2;

        }
    }

}

cout<<c;

return 0;
}

int main()
{ ios_base::sync_with_stdio(false);
    cin.tie(0);
   cout.tie(0);
        //        ifstream abc("input.txt");
        //        ofstream qwe("output.txt");
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  std::vector<char> used(n, false);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    if (used[i]) continue;
    if (b == -1 || d[j] > d[b]) b = j;
    used[b] = true;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j]) {
        v[v][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (q[j] > 0 && (b == -1 || d[j] > d[b] || (d[j] == d[b] && q[j] < q[b]))) {
        b = j;
      }
    }
    if (b == -1) break;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j] == 1) {
        v[b][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  std::vector<char> used(n, false);
  for (int i = 0; i < n; ++i) {
    int b = -1;
    if (used[i]) continue;
    if (b == -1 || d[j] > d[b]) b = j;
    used[b] = true;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j]) {
        v[v][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  int s = 0;
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m-- ) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  std::vector<char> used(n, false);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (used[j]) continue;
      if (b == -1 || d[j] > d[b]) b = j;
    }
    used[b] = true;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j]) {
        v[v][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  std::vector<char> used(n, false);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (used[j]) continue;
      if (b == -1 || d[j] > d[b]) b = j;
    }
    used[b] = true;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j]) {
        v[b][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve()  {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (q[j] > 0 && (b == -1 || d[j] > d[b])) {
        b = j;
      }
    }
    if (b == -1) break;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j] == 1) {
        v[b][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  std::vector<char> used(n, false);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (used[j]) continue;
      if (b == -1 || d[j] > d[b]) b = j;
    }
    used[b] = true;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j]) {
        v[v][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (q[j] > 0 && (b == -1 || d[j] > d[b])) {
        b = j;
      }
    }
    if (b == -1) break;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j] == 1) {
        v[b][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main ()  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (q[j] > 0 && (b == -1 || d[j] > d[b])) {
        b = j;
      }
    }
    if (b == -1) break;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j] == 1) {
        v[b][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  std::vector<char> used(n, false);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (used[j]) continue;
      if (b == -1 || d[j] > d[b]) b = j;
    }
    used[b] = true;
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j]) {
        v[v][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie( nullptr);
    solve();
    return 0;
}


#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <iomanip>

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> d(n);
  for (int& x: d) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> v(n, std::vector<int>(n, 0));
  while (m--) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    v[a][b] = v[b][a] = 1;
  }
  std::vector<int> q(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (v[i][j]) q[i] += d[j];
    }
  }
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int b = -1;
    for (int j = 0; j < n; ++j) {
      if (q[j] > 0 && (b == -1 || d[j] > d[b])) {
        b = j;
      }
    }
    s += q[b];
    q[b] = 0;
    for (int j = 0; j < n; ++j) {
      if (v[b][j] == 1) {
        v[b][j] = v[j][b] = 0;
        q[j] -= d[b];
      }
    }
  }
  std::cout << s;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool my(pair<int,int> x, pair<int,int> y){
        if(x.first>y.first) return true;
        else return false;
}

int main(){

 int n,m;
 cin>>n>>m;
 int t[n];
 vector< pair<int,int> > v(n);
 for(int i=0;i<n;i++){
    cin>>v[i].first;
    t[i]=v[i].first;
    v[i].second=i;
 }
 sort(v.begin(),v.end(),my);

 vector< vector<int> > edge(n);

 for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
 }
unsigned long long cost=0;
 for(int i=0;i<n;i++){
    t[v[i].second]=0;
    for(int j=0;j<edge[v[i].second].size();j++){
        cost+=t[edge[v[i].second][j]];
    }

 }
 cout<<cost<<endl;

}


#include<bits/stdc++.h>
using namespace std;

bool my(pair<int,int> x, pair<int,int> y){
        if(x.first>y.first) return true;
        else return false;

}

int main(){
    int n,m;
    cin>>n>>m;
    int t[n];
    vector< pair<int,int> > v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first;
        t[i]=v[i].first;
        v[i].second=i;
    }
    vector< vector<int> > edge(n);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        v--;
        u--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    sort(v.begin(),v.end(),my);

    long long cost=0;
    for(int i=0;i<n;i++){
        t[v[i].second]=0;
        for(int j=0;j<edge[v[i].second].size();j++){
            cost+=t[edge[v[i].second][j]];
        }
    }

   cout<<cost<<endl;
}


#include<bits/stdc++.h>
using namespace std;

bool my(pair<int,int> x, pair<int,int> y){
        if(x.first>=y.first) return true;
        else return false;

}

int main(){
    int n,m;
    cin>>n>>m;
    int t[n];
    vector< pair<int,int> > v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first;
        t[i]=v[i].first;
        v[i].second=i;
    }
    vector< vector<int> > edge(n);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        v--;
        u--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    sort(v.begin(),v.end(),my);

    long long cost=0;
    for(int i=0;i<n;i++){
        t[v[i].second]=0;
        for(int j=0;j<edge[v[i].second].size();j++){
            cost+=t[edge[v[i].second][j]];
        }
    }

   cout<<cost<<endl;
}


#include <iostream>
#include <set>
using namespace std;

const int inf = 1e9;
const int maxn = 1001;
set<int> g[maxn];
bool was[maxn];

int main() {
	int n, m;
	cin >> n >> m;
	long long sub[n + 1] = {0}, add[n + 1] = {0}, c[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].insert(b);
		g[b].insert(a);
	}
	for(int i = 1; i <= n; i++) {
		for(auto x : g[i]) {
			add[i] += c[x];
		}
		sub[i] = 1ll * c[i] * g[i].size();
	}
	long long ans = 0;
	while(1) {
		int best = inf, cur = -1;
		for(int i = 1; i <= n; i++) {
			if(add[i] - sub[i] < best and !was[i]) {
				best = add[i] - sub[i];
				cur = i;
			}
		}
		if(cur == -1) break;
		ans += add[cur];
		was[cur] = 1;
		for(auto x : g[cur]) {
			g[x].erase(cur);
			sub[x] -= c[x];
			add[x] -= c[cur];
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <set>
using namespace std;

const long long inf = 1e18;
const int maxn = 1001;
set<int> g[maxn];
bool was[maxn];

int main() {
	int n, m;
	cin >> n >> m;
	long long sub[n + 1] = {0}, add[n + 1] = {0}, c[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].insert(b);
		g[b].insert(a);
	}
	for(int i = 1; i <= n; i++) {
		for(auto x : g[i]) {
			add[i] += c[x];
		}
		sub[i] = 1ll * c[i] * g[i].size();
	}
	long long ans = 0;
	while(1) {
		long long best = inf, cur = -1;
		for(int i = 1; i <= n; i++) {
			if(add[i] - sub[i] < best and !was[i]) {
				best = add[i] - sub[i];
				cur = i;
			}
		}
		if(cur == -1) break;
		ans += add[cur];
		was[cur] = 1;
		for(auto x : g[cur]) {
			g[x].erase(cur);
			sub[x] -= c[x];
			add[x] -= c[cur];
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <set>
using namespace std;

const long long inf = 1e18;
const int maxn = 1001;
set<int> g[maxn];
bool was[maxn];

int main() {
	int n, m;
	cin >> n >> m;
	long long sub[n + 1] = {0}, add[n + 1] = {0}, c[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].insert(b);
		g[b].insert(a);
	}
	for(int i = 1; i <= n; i++) {
		for(auto x : g[i]) {
			add[i] += c[x];
		}
		sub[i] = 1ll * c[i] * g[i].size();
	}
	long long ans = 0;
	while(1) {
		long long best = -inf, cur = -1;
		for(int i = 1; i <= n; i++) {
			if(c[i] > best and !was[i]) {
				best = c[i];
				cur = i;
			}
			/*if((add[i] - sub[i] < best or add[i] - sub[i] == best and sub[i] > sub[cur]) and !was[i]) {
				best = add[i] - sub[i];
				cur = i;
			}
			*/
		}
		if(cur == -1) break;
		ans += add[cur];
		was[cur] = 1;
		for(auto x : g[cur]) {
			g[x].erase(cur);
			sub[x] -= c[x];
			add[x] -= c[cur];
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <set>
using namespace std;

const long long inf = 1e18;
const int maxn = 1001;
set<int> g[maxn];
bool was[maxn];

int main() {
	int n, m;
	cin >> n >> m;
	long long sub[n + 1] = {0}, add[n + 1] = {0}, c[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].insert(b);
		g[b].insert(a);
	}
	for(int i = 1; i <= n; i++) {
		for(auto x : g[i]) {
			add[i] += c[x];
		}
		sub[i] = 1ll * c[i] * g[i].size();
	}
	long long ans = 0;
	while(1) {
		long long best = inf, cur = -1;
		for(int i = 1; i <= n; i++) {
			if((add[i] - sub[i] < best or add[i] - sub[i] == best and add[i] < add[cur]) and !was[i]) {
				best = add[i] - sub[i];
				cur = i;
			}
		}
		if(cur == -1) break;
		ans += add[cur];
		was[cur] = 1;
		for(auto x : g[cur]) {
			g[x].erase(cur);
			sub[x] -= c[x];
			add[x] -= c[cur];
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <set>
using namespace std;

const long long inf = 1e18;
const int maxn = 1001;
set<int> g[maxn];
bool was[maxn];

int main() {
	int n, m;
	cin >> n >> m;
	long long sub[n + 1] = {0}, add[n + 1] = {0}, c[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].insert(b);
		g[b].insert(a);
	}
	for(int i = 1; i <= n; i++) {
		for(auto x : g[i]) {
			add[i] += c[x];
		}
		sub[i] = 1ll * c[i] * g[i].size();
	}
	long long ans = 0;
	while(1) {
		long long best = inf, cur = -1;
		for(int i = 1; i <= n; i++) {
			if((add[i] - sub[i] < best or add[i] - sub[i] == best and sub[i] > sub[cur]) and !was[i]) {
				best = add[i] - sub[i];
				cur = i;
			}
		}
		if(cur == -1) break;
		ans += add[cur];
		was[cur] = 1;
		for(auto x : g[cur]) {
			g[x].erase(cur);
			sub[x] -= c[x];
			add[x] -= c[cur];
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

vector <pair<int,int>> v;
vector <int> e[1001];
int d[1001];
bool visit[1001];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m,a,b; cin >> n >> m;
	v.resize(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a, v[i] = { a,i };
		d[i] = a;
	}
	sort(v.begin(), v.end());

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		e[a].push_back(b), e[b].push_back(a);
	}

	int res = 0;
	for (int i = v.size() - 1; i >= 0; i--) {
		int s = v[i].second;
		for (auto a : e[s]) {
			if (!visit[a]) res += d[a];
		}
		visit[s] = 1;
	}
	cout << res << "\n";
}


#include <iostream>
#include <vector>
#include <queue>
#include <vector>
using namespace std;

vector <int> v[1001];
int arr[1001];
int d[1001],cnt[1001];
bool visit[1001];

class Data {
public:
	int a, b, c;
};

bool operator<(Data a, Data b) {
	return a.a > b.a;
}
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m,a,b; cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> arr[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a].push_back(b), v[b].push_back(a);
		d[a] += arr[b];
		cnt[a]++,cnt[b]++;
		d[b] += arr[a];
	}

	priority_queue <Data> q;
	for (int i = 1; i <= n; i++) q.push({(d[i] - cnt[i] * arr[i]),d[i],i });

	int res = 0;
	while (!q.empty()) {
		int t = q.top().a;
		int cost = q.top().b;
		int idx = q.top().c;
		q.pop();

		if (cost > d[idx]) continue;
		res += cost;
		visit[idx] = 1;

		for (auto a : v[idx]) {
			if (!visit[a]) {
				cnt[a]--;
				d[a] -= arr[idx];
				q.push({ d[a] - cnt[a] * arr[a],d[a],a });

			}
		}
	}
	cout << res << "\n";
}


#include <iostream>
#include <vector>
#include <queue>
#include <vector>
using namespace std;

vector <int> v[1001];
int arr[1001];
int d[1001], cnt[1001], dd[1001];
bool visit[1001];

class Data {
public:
	int a, b, c;
};

bool operator<(Data a, Data b) {
	return a.a > b.a;
}
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m,a,b; cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> arr[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a].push_back(b), v[b].push_back(a);
		d[a] += arr[b];
		cnt[a]++,cnt[b]++;
		d[b] += arr[a];
	}

	priority_queue <Data> q;

	for (int i = 1; i <= n; i++) {
		dd[i] = d[i] - cnt[i] * arr[i];
		q.push({dd[i],d[i],i });
	}

	int res = 0;
	while (!q.empty()) {
		int t = q.top().a;
		int cost = q.top().b;
		int idx = q.top().c;
		q.pop();

		if (cost > d[idx] || t > dd[idx]) continue;
		res += cost;
		visit[idx] = 1;

		for (auto a : v[idx]) {
			if (!visit[a]) {
				cnt[a]--;
				d[a] -= arr[idx];
				dd[a] = d[a] - cnt[a] * arr[a];
				q.push({ d[a] - cnt[a] * arr[a],d[a],a });

			}
		}
	}
	cout << res << "\n";
}


#include <iostream>
#include <vector>
#include <queue>
#include <vector>
using namespace std;

vector <int> v[1001];
int arr[1001];
int d[1001],cnt[1001];
bool visit[1001];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m,a,b; cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> arr[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a].push_back(b), v[b].push_back(a);
		d[a] += arr[b];
		cnt[a]++,cnt[b]++;
		d[b] += arr[a];
	}

	priority_queue <pair<int, int>> q;
	for (int i = 1; i <= n; i++) q.push({ -d[i],i });

	int res = 0;
	while (!q.empty()) {
		int cost = -q.top().first;
		int idx = q.top().second;
		q.pop();

		if (cost > d[idx]) continue;
		if (d[idx] - cnt[idx] * arr[idx] > 0) continue;
		res += cost;
		visit[idx] = 1;

		for (auto a : v[idx]) {
			if (!visit[a]) {
				cnt[a]--;
				q.push({ -(d[a] - arr[idx]),a });
				d[a] -= arr[idx];
			}
		}
	}
	cout << res << "\n";
}


#include <iostream>
#include <algorithm>
using namespace std;
int arr[1001];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m,a,b; cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> arr[i];
	int res = 0;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		res += min(arr[a], arr[b]);
	}
	cout << res << "\n";
}


#include <bits/stdc++.h>

using namespace std;

struct Node{
  int id;
  int weight;
  vector<Node *> * neighbours;
};

bool compareFunction(struct Node * a, struct Node * b){
    if (a->weight <= b->weight) return 0;
    else return 1;
}

int main(){

  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  vector<Node *> nodeVector;
  for (int i = 0 ; i < n ; i++){
    struct Node * temp = new Node;
    temp->id = i+1;
    cin >> temp->weight;
    temp->neighbours = new vector<Node *>();
    nodeVector.push_back(temp);
  }
  for (int i = 0 ; i < m ; i++){
    int n1, n2;
    cin >> n1 >> n2;
    (nodeVector[n1-1]->neighbours)->push_back(nodeVector[n2-1]);
    (nodeVector[n2-1]->neighbours)->push_back(nodeVector[n1-1]);
  }

  sort(nodeVector.begin(),nodeVector.end(), compareFunction);

  int energyConsumed = 0;
  for (int i = 0 ; i < n ; i++){
    vector<Node *>::iterator it;
    for (it = (nodeVector[i]->neighbours)->begin() ; it != (nodeVector[i]->neighbours)->end() ; it++){
      energyConsumed += (*it)->weight;
    }
    nodeVector[i]->weight = 0;
  }

  cout<<energyConsumed<<endl;

  return 0;
}


#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define klar(v) memset(v, 0, sizeof(v))
#define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a, b) __gcd(a, b);
#define debug(x) cout << #x << " " << x << endl;
#define endl "\n"

typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const int maxn = 2e3+100;

vi graph[maxn];
ll cost[maxn], price[maxn];
int odw[maxn];

struct cmp{
    bool operator()(int a, int b){
        if(price[a] != price[b])return price[a] > price[b];
        if(cost[a] != cost[b])return cost[a] < cost[b];
        return a < b;
    }
};

set <int, cmp> seth;

ll gemacht(){
    ll ans = 0;
    while(seth.size()){
        int v = *seth.begin(); seth.erase(seth.begin());
        odw[v] = 1;
        ans += cost[v];
        for(auto i: graph[v]){
            if(odw[i])continue;
            seth.erase(i);
            cost[i] -= price[v];
            seth.insert(i);
        }
    }
    return ans;
}

int main(){
    bust
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)cin >> price[i];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    for(int i = 1; i <= n; i++){
        for(auto j: graph[i])cost[i] += price[j];
        seth.insert(i);
    }
    cout << gemacht() << endl;
}


#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define klar(v) memset(v, 0, sizeof(v))
#define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a, b) __gcd(a, b);
#define debug(x) cout << #x << " " << x << endl;
#define endl "\n"

typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const int maxn = 2e3+100;

vi graph[maxn];
ll cost[maxn], price[maxn];
int odw[maxn];

struct cmp{
    bool operator()(int a, int b){
        if(price[a] != price[b])return price[a] > price[b];
        //if(cost[a] != cost[b])return cost[a] < cost[b];
        return a < b;
    }
};

set <int, cmp> seth;

ll gemacht(){
    ll ans = 0;
    while(seth.size()){
        int v = *seth.begin(); seth.erase(seth.begin());
        odw[v] = 1;
        ans += cost[v];
        for(auto i: graph[v]){
            if(odw[i])continue;
            seth.erase(i);
            cost[i] -= price[v];
            seth.insert(i);
        }
    }
    return ans;
}

int main(){
    bust
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)cin >> price[i];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    for(int i = 1; i <= n; i++){
        for(auto j: graph[i])cost[i] += price[j];
        seth.insert(i);
    }
    cout << gemacht() << endl;
}


#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define klar(v) memset(v, 0, sizeof(v))
#define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a, b) __gcd(a, b);
#define debug(x) cout << #x << " " << x << endl;
#define endl "\n"

typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const int maxn = 2e3+100;

vi graph[maxn];
ll cost[maxn], price[maxn];
int odw[maxn];

struct cmp{
    bool operator()(int a, int b){
        if(price[a] != price[b])return price[a] > price[b];
        return a < b;
    }
};

set <int, cmp> seth;

ll gemacht(){
    ll ans = 0;
    while(seth.size()){
        int v = *seth.begin(); seth.erase(seth.begin());
        odw[v] = 1;
        ans += cost[v];
    }
    return ans;
}

int main(){
    bust
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)cin >> price[i];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    for(int i = 1; i <= n; i++)
        seth.insert(i);
    cout << gemacht() << endl;
}


#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define klar(v) memset(v, 0, sizeof(v))
#define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a, b) __gcd(a, b);
#define debug(x) cout << #x << " " << x << endl;
#define endl "\n"

typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const int maxn = 2e3+100;

vi graph[maxn];
ll cost[maxn], price[maxn];
int odw[maxn];

struct cmp{
    bool operator()(int a, int b){
        if(price[a] != price[b])return price[a] > price[b];
        if(cost[a] != cost[b])return cost[a] < cost[b];
        return a < b;
    }
};

set <int, cmp> seth;

ll gemacht(){
    ll ans = 0;
    while(seth.size()){
        int v = *seth.begin(); seth.erase(seth.begin());
        odw[v] = 1;
       // cout << v << " " << cost[v] << endl;
        ans += cost[v];
        for(auto i: graph[v]){
            if(odw[i])continue;
            seth.erase(i);
            cost[i] -= price[v];
            seth.insert(i);
        }
    }
    return ans;
}

int main(){
    bust
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)cin >> price[i];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    for(int i = 1; i <= n; i++){
        for(auto j: graph[i])cost[i] += price[j];
        seth.insert(i);
    }
    cout << gemacht() << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mk make_pair
#define ll long long int
#define pb emplace_back
ll power(ll x,ll y,ll p)//Exponential Modular function.
{
    ll res=1;
    x=x%p;
    while(y>0)
    {
        if(y & 1)
        res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
        return res;
}

ll inverse(ll n,ll p)//Modular inverse function if Mod is Prime.
{
        return power(n,p-2,p);
}
vector<vector<ll>>G;
vector<bool>deleted;
vector<ll>node;
vector<ll>value;
bool compare(ll A, ll B)
{
    return value[A]>=value[B];
}
int main()
{
    sync;
    ll n,m;
    cin>>n>>m;
    G=vector<vector<ll>>(n);
    deleted=vector<bool>(n,false);
    node=vector<ll>(n);
    value=vector<ll>(n);
    for(int i=0;i<n;i++)
    {
        cin>>value[i];
        node[i]=i;
    }
    for(int i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--,v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    sort(node.begin(),node.end(),compare);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(!deleted[node[i]])
        {
            for(auto it:G[node[i]])
            {
                if(!deleted[it])
                ans+=value[it];
            }
            deleted[node[i]]=true;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mk make_pair
#define ll long long int
#define pb emplace_back
ll power(ll x,ll y,ll p)//Exponential Modular function.
{
    ll res=1;
    x=x%p;
    while(y>0)
    {
        if(y & 1)
        res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
        return res;
}

ll inverse(ll n,ll p)//Modular inverse function if Mod is Prime.
{
        return power(n,p-2,p);
}
vector<vector<pair<ll,ll>>>G;
vector<bool>deleted;
vector<pair<ll,ll>>node;
bool compare(pair<ll,ll>A,pair<ll,ll>B)
{
    return A.second>=B.second;
}
int main()
{
    sync;
    ll n,m;
    cin>>n>>m;
    G=vector<vector<pair<ll,ll>>>(n);
    deleted=vector<bool>(n,false);
    node=vector<pair<ll,ll>>(n);
    for(int i=0;i<n;i++)
    {
        node[i].first=i;
        cin>>node[i].second;
    }
    for(int i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--,v--;
        G[u].pb(mk(v,node[v].second));
        G[v].pb(mk(u,node[u].second));
    }
    sort(node.begin(),node.end(),compare);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(!deleted[node[i].first])
        {
            for(auto it:G[node[i].first])
            {
                if(!deleted[it.first])
                ans+=it.second;
            }
            deleted[node[i].first]=true;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mk make_pair
#define ll long long int
#define pb emplace_back
ll power(ll x,ll y,ll p)//Exponential Modular function.
{
    ll res=1;
    x=x%p;
    while(y>0)
    {
        if(y & 1)
        res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
        return res;
}

ll inverse(ll n,ll p)//Modular inverse function if Mod is Prime.
{
        return power(n,p-2,p);
}
int main()
{
    sync;
    ll n,m;
    cin>>n>>m;
    vector<ll>G[n];
    vector<ll>value(n);
    vector<ll>node(n);
    vector<bool>deleted(n,false);
    for(int i=0;i<n;i++)
    {
        cin>>value[i];
        node[i]=i;
    }
    for(int i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--,v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    sort(node.begin(),node.end(),[&](ll x,ll y){ return value[x]>value[y];});
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(!deleted[node[i]])
        {
            for(auto it:G[node[i]])
            {
                if(!deleted[it])
                ans+=value[it];
            }
            deleted[node[i]]=true;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mk make_pair
#define ll long long int
#define pb emplace_back
ll power(ll x,ll y,ll p)//Exponential Modular function.
{
    ll res=1;
    x=x%p;
    while(y>0)
    {
        if(y & 1)
        res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
        return res;
}

ll inverse(ll n,ll p)//Modular inverse function if Mod is Prime.
{
        return power(n,p-2,p);
}
vector<vector<ll>>G;
vector<bool>deleted;
vector<pair<ll,ll>>node;
vector<ll>value;
bool compare(pair<ll,ll>A,pair<ll,ll>B)
{
    return A.second>=B.second;
}
int main()
{
    sync;
    ll n,m;
    cin>>n>>m;
    G=vector<vector<ll>>(n);
    deleted=vector<bool>(n);
    node=vector<pair<ll,ll>>(n);
    value=vector<ll>(n);
    for(int i=0;i<n;i++)
    {
        node[i].first=i;
        cin>>node[i].second;
        value[i]=node[i].second;
    }
    for(int i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--,v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    sort(node.begin(),node.end(),compare);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        deleted[node[i].first]=true;
        for(auto it:G[node[i].first])
        {
            if(!deleted[it])
            {
                ans+=value[it];
            }
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define fr(m,n)for(int i=m; i<n; i++)
#define fr1(k,l)for(int j=k; j<l; j++)
#define ll long long int
#define pb push_back
#define set(a) memset(a,-1,sizeof(a))
#define clr(a) memset(a,0,sizeof(a))
typedef vector <int> ve;
typedef vector <bool> vb;
ve vec[2010];
vb vis;
ll mat[2010][2010];
ll ans=0;
void fun(int u)
{
	//cout<<u<<endl;
	fr(0,vec[u].size())
	{
		int x=vec[u][i];
		//cout<<mat[u][x]<<endl;
		if(mat[u][x])
		{
			ans+=mat[u][x];
			mat[u][x]=0;
			mat[x][u]=0;
		}

	}
}

main()
{
	//freopen("input.txt","r",stdin);
	ll tc,cse=0;
	ll node,edge;
	cin>>node>>edge;
	ll cost[node+1];
	ll a[node+1],b[node+1];
	fr(1,node+1)cin>>cost[i];
	fr(1,edge+1)
	{
		cin>>a[i]>>b[i];
		ll mn=min(cost[a[i]],cost[b[i]]);
		mat[a[i]][b[i]]=mn;
		mat[b[i]][a[i]]=mn;
		vec[a[i]].pb(b[i]);
		vec[b[i]].pb(a[i]);
	}

	fr(1,node+1)
	{
		if(vec[i].size())
			fun(i);
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define fr(m,n)for(int i=m; i<n; i++)
#define fr1(k,l)for(int j=k; j<l; j++)
#define ll long long int
#define pb push_back
#define set(a) memset(a,-1,sizeof(a))
#define clr(a) memset(a,0,sizeof(a))
typedef vector <int> ve;
typedef vector <bool> vb;
ve vec[2010];
vb vis;
ll mat[2010][2010];
ll ans=0;
void fun(int u)
{
	//cout<<u<<endl;
	fr(0,vec[u].size())
	{
		int x=vec[u][i];
		//cout<<mat[u][x]<<endl;
		if(mat[u][x])
		{
			ans+=mat[u][x];
			mat[u][x]=0;
			mat[x][u]=0;
		}

	}
}

main()
{
	//freopen("input.txt","r",stdin);
	ll tc,cse=0;
	ll node,edge;
	cin>>node>>edge;
	ll cost[node+100];
	ll a[edge+1],b[edge+1];
	fr(1,node+1)cin>>cost[i];
	fr(1,edge+1)
	{
		cin>>a[i]>>b[i];
		ll mn=min(cost[a[i]],cost[b[i]]);
		mat[a[i]][b[i]]=mn;
		mat[b[i]][a[i]]=mn;
		vec[a[i]].pb(b[i]);
		vec[b[i]].pb(a[i]);
	}

	fr(1,node+1)
	{
		if(vec[i].size())
			fun(i);
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define fr(m,n)for(int i=m; i<n; i++)
#define fr1(k,l)for(int j=k; j<l; j++)
#define ll long long int
#define pb push_back
#define set(a) memset(a,-1,sizeof(a))
#define clr(a) memset(a,0,sizeof(a))
typedef vector <int> ve;
typedef vector <bool> vb;
ve vec[1001];
vb vis;

main()
{
	//freopen("input.txt","r",stdin);
	ll tc,cse=0;
	ll node,edge;
	cin>>node>>edge;
	ll cost[node+1];
	ll mat[node+1][node+1],a[node+1],b[node+1];
	fr(1,node+1)cin>>cost[i];
	fr(1,edge+1)
	{
		cin>>a[i]>>b[i];
		ll mn=min(cost[a[i]],cost[b[i]]);
		mat[a[i]][b[i]]=mn;
	}

	ll ans=0;
	fr(1,edge+1)
	{
		ans+=mat[a[i]][b[i]];
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define fr(m,n)for(int i=m; i<n; i++)
#define fr1(k,l)for(int j=k; j<l; j++)
#define ll long long int
#define pb push_back
#define set(a) memset(a,-1,sizeof(a))
#define clr(a) memset(a,0,sizeof(a))
typedef vector <int> ve;
typedef vector <bool> vb;
ve vec[1001];
vb vis;

main()
{
	//freopen("input.txt","r",stdin);
	int tc,cse=0;
	int node,edge;
	cin>>node>>edge;
	int cost[node+1];
	int mat[node+1][node+1],a[node+1],b[node+1];
	fr(1,node+1)cin>>cost[i];
	fr(1,edge+1)
	{
		cin>>a[i]>>b[i];
		int mn=min(cost[a[i]],cost[b[i]]);
		mat[a[i]][b[i]]=mn;
	}

	int ans=0;
	fr(1,edge+1)
	{
		ans+=mat[a[i]][b[i]];
	}
	cout<<ans<<endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef pair<int, int> ii;
const int N = 1003;
const ll INF = 1e18;
int grid[N][N],cost[N];
ii val[N];
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif // !ONLINE_JUDGE
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> cost[i];
		val[i].first = cost[i];
		val[i].second = i;
	}
	sort(val, val + n);
	reverse(val, val + n);
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--, b--;
		grid[a][b] = grid[b][a] = 1;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int node = val[i].second;
		for (int j = 0; j < n; j++) {
			if (grid[node][j] == 1) {
				ans += cost[j];
				grid[node][j] = grid[j][node] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef pair<int, int> ii;
const int N = 1003;
const ll INF = 1e18;
int cost[N],vis[N];
vector<vector<int>>adjlist;
vector<int>sol;
vector<ii>in;
void dfs(int node) {
	if (vis[node])return;
	vis[node] = 1;
	for (int i = 0; i < adjlist[node].size(); i++)
	{
		int child = adjlist[node][i];
		if (!vis[child])
			dfs(child);
	}
	sol.push_back(node);
}

int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif // !ONLINE_JUDGE
	int n, m; cin >> n >> m;
	adjlist.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> cost[i];
		in.push_back({ cost[i], i });
	}
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--, b--;
		if (cost[a] > cost[b])
			adjlist[a].push_back(b);
		else adjlist[b].push_back(a);
	}
	sort(in.begin(), in.end());
	for (int i = 0; i < in.size(); i++)
		dfs(in[i].second);
	reverse(sol.begin(), sol.end());

	memset(vis, 0, sizeof vis);

	ll ans = 0;
	for (int i = 0; i < sol.size(); i++) {
		vis[sol[i]] = 1;
		for (int j = 0; j < adjlist[sol[i]].size(); j++) {
			int child = adjlist[sol[i]][j];
			if (!vis[child])ans += cost[child];
		}
	}
	cout << ans << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef pair<int, int> ii;
const int N = 1003;
const ll INF = 1e18;
int cost[N],vis[N];
vector<vector<int>>adjlist;
vector<int>sol;
void dfs(int node) {
	if (vis[node])return;
	vis[node] = 1;
	for (int i = 0; i < adjlist[node].size(); i++)
	{
		int child = adjlist[node][i];
		if (!vis[child])
			dfs(child);
	}
	sol.push_back(node);
}

int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif // !ONLINE_JUDGE
	int n, m; cin >> n >> m;
	adjlist.resize(n);
	for (int i = 0; i < n; i++)
		cin >> cost[i];
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--, b--;
		if (cost[a] > cost[b])
			adjlist[a].push_back(b);
		else adjlist[b].push_back(a);
	}
	for (int i = 0; i < n; i++)
		dfs(i);
	reverse(sol.begin(), sol.end());

	memset(vis, 0, sizeof vis);

	ll ans = 0;
	for (int i = 0; i < sol.size(); i++) {
		vis[sol[i]] = 1;
		for (int j = 0; j < adjlist[sol[i]].size(); j++) {
			int child = adjlist[sol[i]][j];
			if (!vis[child])ans += cost[child];
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 10000000000000007LL
#define maxN 10007

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
#define mt make_tuple

// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vll>
#define iii tuple <int, int, int>
#define iiii tuple <int, int, int, int>

// get value
#define FF first
#define SS second
#define get(x, a) get<(x)>(a)

// data type
#define ll long long
#define ull unsigned long long

// function
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

vi adj[maxN];
int a[maxN];
bool visited[maxN];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("tmp.inp", "r", stdin);
        freopen("tmp.out", "w", stdout);
    #endif // ONLINE_JUDGE

    int n, m;
    scanf("%d%d", &n, &m);

    int ans = 0;
    fto (i, 1, n) scanf("%d", &a[i]);
    fto (i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);

        ans += min(a[u], a[v]);
    }

    printf("%d\n", ans);

    return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 10000000000000007LL
#define maxN 107

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
#define mt make_tuple

// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vll>
#define iii tuple <int, int, int>
#define iiii tuple <int, int, int, int>

// get value
#define FF first
#define SS second
#define get(x, a) get<(x)>(a)

// data type
#define ll long long
#define ull unsigned long long

// function
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

vi adj[maxN];
int a[maxN];
bool visited[maxN];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("tmp.inp", "r", stdin);
        freopen("tmp.out", "w", stdout);
    #endif // ONLINE_JUDGE

    int n, m;
    scanf("%d%d", &n, &m);

    fto (i, 1, n) scanf("%d", &a[i]);
    fto (i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);

        adj[u].pb(v);
        adj[v].pb(u);
    }

    int minPrice = 0;
    fto (i, 1, n) {
        int ans = 0;
        int cur = 0;
        fto (u, 1, n) {
            int res = 0;
            if (visited[u]) continue;
            fto (j, 0, (int)adj[u].size()-1) {
                int v = adj[u][j];
                if (!visited[v]) res += a[u];
            }
            if (res >= ans) {
                ans = res;
                cur = u;
            }
        }
        visited[cur] = 1;
        ans = 0;
        fto (j, 0, (int)adj[cur].size()-1) {
            int v = adj[cur][j];
            if (!visited[v]) ans += a[v];
        }
        minPrice += ans;
    }

    printf("%d\n", minPrice);

    return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 10000000000000007LL
#define maxN 107

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
#define mt make_tuple

// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vll>
#define iii tuple <int, int, int>
#define iiii tuple <int, int, int, int>

// get value
#define FF first
#define SS second
#define get(x, a) get<(x)>(a)

// data type
#define ll long long
#define ull unsigned long long

// function
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

vi adj[maxN];
int a[maxN];
bool visited[maxN];

int main() {
    #ifndef ONLINE_JUDGE
        freopen("tmp.inp", "r", stdin);
        freopen("tmp.out", "w", stdout);
    #endif // ONLINE_JUDGE

    int n, m;
    scanf("%d%d", &n, &m);

    int ans = 0;
    fto (i, 1, n) scanf("%d", &a[i]);
    fto (i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);

        ans += min(a[u], a[v]);
    }

    printf("%d\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
int val[N];

int main()
{
	IOS
	freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		cin >> val[i];
	}
	int ans = 0;
	while(m--){
		int u, v; cin >> u >> v;
		ans += min(val[u], val[v]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
int val[N];

int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		cin >> val[i];
	}
	int ans = 0;
	while(m--){
		int u, v; cin >> u >> v;
		ans += min(val[u], val[v]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, k;
int a[N][N];

int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			cin >> a[i][j];
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			a[i][j] += a[i][j-1];
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			a[i][j] += a[i-1][j];
		}
	}
	int ans = 0;
	for(int i=k; i<=n; i++){
		for(int j=k; j<=n; j++){
			ans = max(ans, a[i][j] - a[i-k][j] - a[i][j-k] + a[i-k][j-k]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define in freopen("input.txt", "r", stdin)
#define fr first
#define sc second
using namespace std;
ll n , m;
ll f[20005];
vector<ll> g[20005];
pair <ll ,ll> p[20005];

bool used[10005];

bool flag = false;

ll calc (ll v){
    ll sum  = 0;

    used[v] = 1;
    for (int i = 0; i < g[v].size(); i++) {
        ll to = g[v][i];
        if (!used[to]){
            sum += f[to];
        }
    }
    return sum;
}

int main() {
  // in;
   cin >> n >> m;
   for (int i = 1; i <= n; i++) {
        cin >> f[i];
        p[i].fr = f[i];
        p[i].sc = i;
   }

   for (int i = 1; i <= m; i++) {
        ll x, y;
        cin >> x >> y;
        g[x].pb (y);
        g[y].pb (x);
   }

    sort (p + 1, p + 1 + n);

    ll ans = 0;
    for (int i = n; i >= 1; i--) {
    if (!used[p[i].sc])
        ans += calc(p[i].sc);
    }
    cout << ans;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define in freopen("input.txt", "r", stdin)
#define fr first
#define sc second
using namespace std;
ll n , m;
ll f[20005];
int main() {
  // in;
   cin >> n >> m;
   for (int i = 1; i <= n; i++) {
        cin >> f[i];
   }
    ll ans = 0;
   for (int i = 1; i <= m; i++) {
        ll x, y;
        cin >> x >> y;
        ans += min (f[x], f[y]);
   }
    cout << ans;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define in freopen("input.txt", "r", stdin)
#define fr first
#define sc second
using namespace std;
ll n , m;
ll f[20005];
vector<ll> g[20005];
pair <ll ,ll> p[20005];

bool used[10005];

bool flag = false;

ll calc (ll v){
    ll sum  = 0;

    used[v] = 1;
    for (int i = 0; i < g[v].size(); i++) {
        ll to = g[v][i];
        if (!used[to]){
            sum += f[to];
        }
    }
    return sum;
}

int main() {
   in;
   cin >> n >> m;
   for (int i = 1; i <= n; i++) {
        cin >> f[i];
        p[i].fr = f[i];
        p[i].sc = i;
   }

   for (int i = 1; i <= m; i++) {
        ll x, y;
        cin >> x >> y;
        g[x].pb (y);
        g[y].pb (x);
   }

    sort (p + 1, p + 1 + n);

    ll ans = 0;
    for (int i = n; i >= 1; i--) {
    if (!used[p[i].sc])
        ans += calc(p[i].sc);
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

void inp()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
ll min(ll a,ll b)
{
    if(a<b)
        return a;
    else
        return b;
}

ll max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}

bool mycompare(pair<ll,ll> &a,pair<ll,ll> &b)
{
	return a.first>=b.first;
}

int main() {

    	ll n,m;
    	cin>>n>>m;

    	vector<pair<ll,ll>> v;
      	map<ll,ll> val;
      	for(ll i=1;i<=n;i++)
      	{
      		ll x;
      		cin>>x;
      		v.push_back({x,i});
      		val[i]=x;
      	}
      	vector<vector<ll>> graph(n+1);
      	for(ll i=0;i<m;i++)
      	{
      		ll u,v;
      		cin>>u>>v;
      		graph[u].push_back(v);
      		graph[v].push_back(u);
      	}

      	sort(v.begin(),v.end(),mycompare);

      	map<ll,bool> mp;
      	ll ans=0;
      	for(auto s:v)
      	{
      		ll e=s.first;
      		ll u=s.second;

      		//cout<<u<<endl;
      		for(ll i=0;i<graph[u].size();i++)
      		{
      			//cout<<graph[u][i]<<" ";
      			if(!mp[graph[u][i]])
      			{
      				ans+=val[graph[u][i]];
      			}
      		}
      		//cout<<endl;
      		mp[u]=true;
      	}
      	cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

void inp()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
ll min(ll a,ll b)
{
    if(a<b)
        return a;
    else
        return b;
}

ll max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}

bool mycompare(pair<int,int> &a,pair<int,int> &b)
{
	return a.first>=b.first;
}

int main() {

    	int n,m;
    	cin>>n>>m;

    	vector<pair<int,int>> v;
      	map<int,int> val;
      	for(int i=1;i<=n;i++)
      	{
      		int x;
      		cin>>x;
      		v.push_back({x,i});
      		val[i]=x;
      	}
      	vector<vector<int>> graph(n+1);
      	for(int i=0;i<m;i++)
      	{
      		int u,v;
      		cin>>u>>v;
      		graph[u].push_back(v);
      		graph[v].push_back(u);
      	}

      	sort(v.begin(),v.end(),mycompare);

      	map<int,bool> mp;
      	ll ans=0;
      	for(auto s:v)
      	{
      		int e=s.first;
      		int u=s.second;

      		//cout<<u<<endl;
      		for(int i=0;i<graph[u].size();i++)
      		{
      			//cout<<graph[u][i]<<" ";
      			if(!mp[graph[u][i]])
      			{
      				ans+=val[graph[u][i]];
      			}
      		}
      		//cout<<endl;
      		mp[u]=true;
      	}
      	cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

void inp()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
ll min(ll a,ll b)
{
    if(a<b)
        return a;
    else
        return b;
}

ll max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}

bool mycompare(pair<ll,ll> &a,pair<ll,ll> &b)
{
	return a.first>=b.first;
}

int main() {

    	ll n,m;
    	cin>>n>>m;

    	vector<pair<ll,ll>> v;
      	map<ll,ll> val;
      	for(ll i=1;i<=n;i++)
      	{
      		ll x;
      		cin>>x;
      		v.push_back({x,i});
      		val[i]=x;
      	}
      	ll ans=0;
      	vector<vector<ll>> graph(n+1);
      	for(ll i=0;i<m;i++)
      	{
      		ll u,v;
      		cin>>u>>v;
      		graph[u].push_back(v);
      		graph[v].push_back(u);
      		ans+=min(val[u],val[v]);
      	}

      	// sort(v.begin(),v.end(),mycompare);

      	// map<ll,bool> mp;
      	// ll ans=0;
      	// for(auto s:v)
      	// {
      	// 	ll e=s.first;
      	// 	ll u=s.second;

      	// 	//cout<<u<<endl;
      	// 	for(ll i=0;i<graph[u].size();i++)
      	// 	{
      	// 		//cout<<graph[u][i]<<" ";
      	// 		if(!mp[graph[u][i]])
      	// 		{
      	// 			ans+=val[graph[u][i]];
      	// 		}
      	// 	}
      	// 	//cout<<endl;
      	// 	mp[u]=true;
      	// }
      	cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

void inp()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
ll min(ll a,ll b)
{
    if(a<b)
        return a;
    else
        return b;
}

ll max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}

bool mycompare(pair<int,int> &a,pair<int,int> &b)
{
	return a.first>=b.first;
}

int main() {

    	int n,m;
    	cin>>n>>m;

    	vector<pair<int,int>> v;
      	map<int,int> val;
      	for(int i=1;i<=n;i++)
      	{
      		int x;
      		cin>>x;
      		v.push_back({x,i});
      		val[i]=x;
      	}
      	vector<vector<int>> graph(n+1);
      	for(int i=0;i<m;i++)
      	{
      		int u,v;
      		cin>>u>>v;
      		graph[u].push_back(v);
      		graph[v].push_back(u);
      	}

      	sort(v.begin(),v.end(),mycompare);

      	map<int,bool> mp;
      	int ans=0;
      	for(auto s:v)
      	{
      		int e=s.first;
      		int u=s.second;

      		//cout<<u<<endl;
      		for(int i=0;i<graph[u].size();i++)
      		{
      			//cout<<graph[u][i]<<" ";
      			if(!mp[graph[u][i]])
      			{
      				ans+=val[graph[u][i]];
      			}
      		}
      		//cout<<endl;
      		mp[u]=true;
      	}
      	cout<<ans<<endl;

    return 0;
}


#include <bits\stdc++.h>
using namespace std;
void fastInOout();

int cost[1111], deleteCost[1111];
vector<int> adj[1111];
int main() {
	fastInOout();
	int n, m, u, v;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> cost[i];
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < adj[i].size(); j++) {
			deleteCost[i] += cost[adj[i][j]];
		}
	}
	long long totCost = 0; int deletedno = 0;
	for (int i = 0; i < n-1 && deletedno <= n-1; i++) {
		int mn = INT_MAX, mnInd = -1;
		for (int j = 1; j <= n; j++) {
			if ((deleteCost[j] != 0) &&  ((deleteCost[j] < mn) || (deleteCost[j] == mn && cost[j] > cost[mnInd]))) {
				mn = deleteCost[j]; mnInd = j;
			}
		}
		totCost += deleteCost[mnInd];
		deleteCost[mnInd] = 0;
		deletedno++;
		for (int j = 0; j < adj[mnInd].size(); j++) {
			deleteCost[adj[mnInd][j]] = max(deleteCost[adj[mnInd][j]] - cost[mnInd], 0);
			if (deleteCost[adj[mnInd][j]] == 0) deletedno++;
		}
	}
	cout << totCost << endl;
}
void fastInOout() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}


#include <bits\stdc++.h>
using namespace std;
void fastInOout();

long long cost[1111], deleteCost[1111];
vector<int> adj[1111];
int main() {
	fastInOout();
	int n, m, u, v;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> cost[i];
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < adj[i].size(); j++) {
			deleteCost[i] += cost[adj[i][j]];
		}
	}
	long long totCost = 0; int deletedno = 0;
	for (int i = 0; i < n-1 && deletedno <= n-1; i++) {
		long long mn = LLONG_MAX; int mnInd = -1;
		for (int j = 1; j <= n; j++) {
			if ((deleteCost[j] != 0) &&  ((deleteCost[j] < mn) || (deleteCost[j] == mn && cost[j] > cost[mnInd]))) {
				mn = deleteCost[j]; mnInd = j;
			}
		}
		totCost += deleteCost[mnInd];
		deleteCost[mnInd] = 0;
		deletedno++;
		for (int j = 0; j < adj[mnInd].size(); j++) {
			deleteCost[adj[mnInd][j]] = max(deleteCost[adj[mnInd][j]] - cost[mnInd], (long long) 0);
			if (deleteCost[adj[mnInd][j]] == 0) deletedno++;
		}
	}
	cout << totCost << endl;
}
void fastInOout() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}


#include <bits\stdc++.h>
using namespace std;
void fastInOout();

int main() {
	fastInOout();
	int n, m, u, v, a[111111], cost=0;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		cost += min(a[u], a[v]);
	}
	cout << cost << endl;
}

void fastInOout() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}


#include <bits\stdc++.h>
using namespace std;
void fastInOout();

int cost[1111], deleteCost[1111];
vector<int> adj[1111];
int main() {
	fastInOout();
	int n, m, u, v;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> cost[i];
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < adj[i].size(); j++) {
			deleteCost[i] += cost[adj[i][j]];
		}
	}
	int totCost = 0, deletedno = 0;
	for (int i = 0; i < n-1 && deletedno <= n-1; i++) {
		int mn = INT_MAX, mnInd = -1;
		for (int j = 1; j <= n; j++) {
			if ((deleteCost[j] != 0) &&  ((deleteCost[j] < mn) || (deleteCost[j] == mn && cost[j] > cost[mnInd]))) {
				mn = deleteCost[j]; mnInd = j;
			}
		}
		totCost += deleteCost[mnInd];
		deleteCost[mnInd] = 0;
		deletedno++;
		for (int j = 0; j < adj[mnInd].size(); j++) {
			deleteCost[adj[mnInd][j]] = max(deleteCost[adj[mnInd][j]] - cost[mnInd], 0);
			if (deleteCost[adj[mnInd][j]] == 0) deletedno++;
		}
	}
	cout << totCost << endl;
}
void fastInOout() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}


#include<bits/stdc++.h>
using namespace std;
int vec[1000000];
int main()
{
    int n,m;
    int i,j,e;

for(i=0;i<n;i++)
{
    cin>>vec[i];

}
int sum=0;
int f,s;
for(i=0;i<m;i++)
{cin>>f>>s;
sum=sum+min(vec[f-1],vec[s-1]);

}
cout<<sum;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    int i,j,e;
vector<int> vec;
for(i=0;i<n;i++)
{
    cin>>e;
    vec.push_back(e);
}
int sum=0;
int f,s;
for(i=0;i<m;i++)
{cin>>f>>s;
sum=sum+min(vec[f-1],vec[s-1]);

}
cout<<sum;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int vec[1000000];
int main()
{
    int n,m;
    int i,j,e;
cin>>n>>m;
for(i=0;i<n;i++)
{
    cin>>vec[i];

}
int sum=0;
int f,s;
for(i=0;i<m;i++)
{cin>>f>>s;
sum=sum+min(vec[f-1],vec[s-1]);

}
cout<<sum;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int M  = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
/*int fac[M]={0};*/
//int dp[M]={0};
#define ll long long
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
// Use __gcd(int, int) as inbuilt function.
/*int spf[M];
void sieve(int MaxN){
	spf[1] = 1;
	for(int i = 2; i<MaxN; i++){
		spf[i] = i;
	}
	for(int i = 4; i<MaxN; i+=2){
		spf[i] = 2;
	}
	for(int i = 3; i*i <MaxN; i++){
		if(spf[i]==i){
			for(int j = i*i; j<MaxN; j+=i){
				if(spf[j]==j){
					spf[j] = i;
				}
			}
		}
	}
}
vector<int> factorise(int x){
	vector<int> factor;
	while(x!=1){
		factor.push_back(spf[x]);
		x = x / spf[x];
	}
	return factor;
}*/
void precompute(){

}
int max3(int x, int y, int z){
    return max(x, max(y,z));
}
long long int power(long long int x, unsigned int y, int p)
{
    long long int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
long long int modinv(long long int x, int p){
    return (power(x, p-2, p));
}
bool compare(const pair<int, int> &p1, const pair<int, int> &p2){
    return (p1.first> p2.first);
}
/*long long int nCrModP(long long int n, long long int r, long long int p)
{
   if (r==0)
      return 1;
    return (fac[n] * modinv(fac[r], p) % p * modinv(fac[n-r], p) % p) % p;
}
vector<int> graph[M];
int flag[M];
void DFS(int i){
    for(auto x: graph[i]){
        //cout<<x<<" ";
        if(flag[x]==-1){
            flag[x]=1;
            DFS(x);
        }
    }
}
void insertgraph(int m){
    for(int i= 0; i<m; i++){
        int u, v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
}
*/

int main(){
    #ifdef SARTHAK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t=1;
    cin>>t;
    precompute();
    while(t--){
        int n, m;
        cin>>n>>m;
        int ar[n];
        for(int i = 0; i<n; i++){
        	cin>>ar[i];
        }
        ll sum = 0;
        int u, v;
        for(int i = 0; i<m; i++){
        	cin>>u>>v;
        	sum += min(ar[u-1], ar[v--]);
        }
    }
    #ifdef SARTHAK
    auto end = chrono::high_resolution_clock::now();
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count(); time_taken *= 1e-9;
    cout << "\nTime taken by program is : " << fixed << time_taken << setprecision(9); cout << " sec" << endl;
    #endif
   	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int M  = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
/*int fac[M]={0};*/
//int dp[M]={0};
#define ll long long
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
// Use __gcd(int, int) as inbuilt function.
/*int spf[M];
void sieve(int MaxN){
	spf[1] = 1;
	for(int i = 2; i<MaxN; i++){
		spf[i] = i;
	}
	for(int i = 4; i<MaxN; i+=2){
		spf[i] = 2;
	}
	for(int i = 3; i*i <MaxN; i++){
		if(spf[i]==i){
			for(int j = i*i; j<MaxN; j+=i){
				if(spf[j]==j){
					spf[j] = i;
				}
			}
		}
	}
}
vector<int> factorise(int x){
	vector<int> factor;
	while(x!=1){
		factor.push_back(spf[x]);
		x = x / spf[x];
	}
	return factor;
}*/
void precompute(){

}
int max3(int x, int y, int z){
    return max(x, max(y,z));
}
long long int power(long long int x, unsigned int y, int p)
{
    long long int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
long long int modinv(long long int x, int p){
    return (power(x, p-2, p));
}
bool compare(const pair<int, int> &p1, const pair<int, int> &p2){
    return (p1.first> p2.first);
}
/*long long int nCrModP(long long int n, long long int r, long long int p)
{
   if (r==0)
      return 1;
    return (fac[n] * modinv(fac[r], p) % p * modinv(fac[n-r], p) % p) % p;
}
vector<int> graph[M];
int flag[M];
void DFS(int i){
    for(auto x: graph[i]){
        //cout<<x<<" ";
        if(flag[x]==-1){
            flag[x]=1;
            DFS(x);
        }
    }
}
void insertgraph(int m){
    for(int i= 0; i<m; i++){
        int u, v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
}
*/

int main(){
    #ifdef SARTHAK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t=1;
    //cin>>t;
    precompute();
    while(t--){
        int n, m;
        cin>>n>>m;
        int ar[n];
        for(int i = 0; i<n; i++){
        	cin>>ar[i];
        }
        ll sum = 0;
        int u, v;
        for(int i = 0; i<m; i++){
        	cin>>u>>v;
        	sum += min(ar[u-1], ar[v--]);
        }
        cout<<sum;
    }
    #ifdef SARTHAK
    auto end = chrono::high_resolution_clock::now();
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count(); time_taken *= 1e-9;
    cout << "\nTime taken by program is : " << fixed << time_taken << setprecision(9); cout << " sec" << endl;
    #endif
   	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int M  = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
/*int fac[M]={0};*/
//int dp[M]={0};
#define ll long long
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
// Use __gcd(int, int) as inbuilt function.
/*int spf[M];
void sieve(int MaxN){
	spf[1] = 1;
	for(int i = 2; i<MaxN; i++){
		spf[i] = i;
	}
	for(int i = 4; i<MaxN; i+=2){
		spf[i] = 2;
	}
	for(int i = 3; i*i <MaxN; i++){
		if(spf[i]==i){
			for(int j = i*i; j<MaxN; j+=i){
				if(spf[j]==j){
					spf[j] = i;
				}
			}
		}
	}
}
vector<int> factorise(int x){
	vector<int> factor;
	while(x!=1){
		factor.push_back(spf[x]);
		x = x / spf[x];
	}
	return factor;
}*/
void precompute(){

}
int max3(int x, int y, int z){
    return max(x, max(y,z));
}
long long int power(long long int x, unsigned int y, int p)
{
    long long int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
long long int modinv(long long int x, int p){
    return (power(x, p-2, p));
}
bool compare(const pair<int, int> &p1, const pair<int, int> &p2){
    return (p1.first> p2.first);
}
/*long long int nCrModP(long long int n, long long int r, long long int p)
{
   if (r==0)
      return 1;
    return (fac[n] * modinv(fac[r], p) % p * modinv(fac[n-r], p) % p) % p;
}
vector<int> graph[M];
int flag[M];
void DFS(int i){
    for(auto x: graph[i]){
        //cout<<x<<" ";
        if(flag[x]==-1){
            flag[x]=1;
            DFS(x);
        }
    }
}
void insertgraph(int m){
    for(int i= 0; i<m; i++){
        int u, v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
}
*/

int main(){
    #ifdef SARTHAK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t=1;
    //cin>>t;
    precompute();
    while(t--){
        int n, m;
        cin>>n>>m;
        ll ar[n];
        for(int i = 0; i<n; i++){
        	cin>>ar[i];
        }
        ll sum = 0;
        int u, v;
        for(int i = 0; i<m; i++){
        	cin>>u>>v;
        	sum += min(ar[u-1], ar[v-1]);
        }
        cout<<sum;
    }
    #ifdef SARTHAK
    auto end = chrono::high_resolution_clock::now();
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count(); time_taken *= 1e-9;
    cout << "\nTime taken by program is : " << fixed << time_taken << setprecision(9); cout << " sec" << endl;
    #endif
   	return 0;
}


#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>

using namespace std;
const double pi=acos(-1.0);
#define boost  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define sl(n) scanf("%lld",&n)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define f(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rf(i,a,b) for(ll i = (ll)(a); i > (ll)(b); i--)
#define ms(a,b) memset((a),(b),sizeof(a))
#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define vec(g1) int temp;cin>>temp;g1,push_back(temp);
#define abs(x) ((x<0)?(-(x)):(x))
#define MAX 1000005
#define inf LLONG_MAX
#define MIN INT_MIN
//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
	int n,m;
	cin>>n>>m;
	 int a[n+1];
	 a[0]=-1;
	 for(int i=1;i<=n;i++)cin>>a[i];
	 	ll sum=0;
	 for(int j=0;j<m;j++){
	 	int x,y;
	 	cin>>x>>y;
	 sum=sum+min(a[x],a[y]);
	 }
	 cout<<sum<<endl;

 	return 0;
}


#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>

using namespace std;
#define boost  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define s(n) scanf("%d",&n)

#define ll long long
#define f(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)

/**.................................................................................................................................*/
int a[1005];
int n,m,x,y;

int main(){
	boost
	s(n);s(m);
	 a[0]=-1;
	 f(i,1,n+1)s(a[i]);
	 	ll sum=0;
	 f(j,0,m){
	 	s(x);s(y);
	 sum+=min(a[x],a[y]);
	 }
        printf("%lld",sum);
 	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

void fs(int &x)
    {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n,m,i,j;
    int ans = 0;
    cin >> n >> m;
    vi v(n);
    vpii x(m);
    Fo(i,1,n+1)cin >> v[i];
    fo(i,m){
        int a,b;
        cin >> a >> b;
        x[i] = mp(v[a],v[b]);
    }

    fo(i,m){
        ans += min(x[i].F, x[i].S);
    }

    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

void fs(int &x)
    {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n,m,i,j;
    ll ans = 0;
    cin >> n >> m;
    vi v(n);
    vpii x(m);
    Fo(i,1,n+1)cin >> v[i];
    fo(i,m){
        int a,b;
        cin >> a >> b;
        x[i] = mp(v[a],v[b]);
    }

    fo(i,m){
        ans += min(x[i].F, x[i].S);
    }

    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

void fs(int &x)
    {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n,m,i,j;
    ll ans = 0;
    cin >> n >> m;
    vl v(n);
    vpl x(m);
    Fo(i,1,n+1)cin >> v[i];
    fo(i,m){
        int a,b;
        cin >> a >> b;
        x[i] = mp(v[a],v[b]);
    }

    fo(i,m){
        ans += min(x[i].F, x[i].S);
    }

    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int MaxN = 100010;
int Ans, V[MaxN], N, M;

int main()
{
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= N; i++) scanf("%d", &V[i]);
    for (int i = 1; i <= M; i++) {
        int X, Y;
        scanf("%d%d", &X, &Y);
        Ans += min(V[X], V[Y]);
    }
    printf("%d\n", Ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll n , m , a , b;
int main(){
	//ios::sync_with_stdio(false);
	ll arr[n+100];
	scanf("%lld %lld", &n, &m);
	ll ans = 0;
	for(int i = 1 ; i <= n ; i++)
		cin >> arr[i];
	for(int  i = 1 ; i <= m ; i++){
		cin >> a >> b;
	ans = ans + min( arr[a] , arr[b] );
	}
	printf("%lld\n", ans);
}


#include <iostream>
using namespace std;
#define ll long long int
int n , m , a , b;
int main(){
	//ios::sync_with_stdio(false);
	int arr[n+100];
	scanf("%d %d", &n, &m);
	int ans = 0;
	for(int i = 1 ; i <= n ; i++){
		scanf("%d", &arr[i]);
	}
	for(int  i = 1 ; i <= m ; i++){
		scanf("%d %d", &a, &b);
		ans = ans + min( arr[a] , arr[b] );
	}
	printf("%d\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll n , m , a , b;
ll arr[1000+5];
int main(){
	// ll n , m ;
	// int a , b;

	cin >> n >> m;
	ll ans = 0;
	for(int i = 1 ; i <= n ; i++)
		cin >> arr[i];
	for(int  i = 1 ; i <= m ; i++){
		cin >> a >> b;
	ans = ans + min( arr[a] , arr[b] );
	}
	cout << ans <<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll n , m , a , b;
int main(){
	//ios::sync_with_stdio(false);
	ll arr[n+100];
	scanf("%lld %lld", &n, &m);
	ll ans = 0;
	for(int i = 1 ; i <= n ; i++){
		scanf("%lld", &arr[i]);
	}
	for(int  i = 1 ; i <= m ; i++){
		scanf("%lld %lld", &a, &b);
		ans = ans + min( arr[a] , arr[b] );
	}
	printf("%lld\n", ans);
}


#include <iostream>
using namespace std;
#define ll long long int
int n , m , a , b;
int arr[100010];
int main(){
	//ios::sync_with_stdio(false);
	scanf("%d %d", &n, &m);
	int ans = 0;
	for(int i = 1 ; i <= n ; i++){
		scanf("%d", &arr[i]);
	}
	for(int  i = 1 ; i <= m ; i++){
		scanf("%d %d", &a, &b);
		ans = ans + min( arr[a] , arr[b] );
	}
	printf("%d\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll n , m , a , b;
int main(){
	//ios::sync_with_stdio(false);
	ll arr[n+100];
	scanf("%lld %lld", &n, &m);
	ll ans = 0;
	for(int i = 1 ; i <= n ; i++){
		cin >> arr[i];
	}
	for(int  i = 1 ; i <= m ; i++){
		cin >> a >> b;
		ans = ans + min( arr[a] , arr[b] );
	}
	printf("%lld\n", ans);
}