#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

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

    vi a(n);
    for (auto& i : a)
        cin >> i;

    int sol = 0;
    for (int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        --u;
        --v;

        if (a[u] >= 0 && a[v] >= 0)
            sol += a[u] + a[v];
        if (a[u] <= 0 && a[v] <= 0)
            sol += abs(a[u]) + abs(a[v]);
        if (a[u] * a[v] >= 0) continue;

        if (abs(a[u]) >= abs(a[v])){
            sol += abs(a[u]) - abs(a[v]);
        } else {
            sol += abs(a[v]) - abs(a[u]);
        }
    }

    cout << sol << '\n';
}