#include <bits/stdc++.h>
#include <bits/stdtr1c++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define amfetamin ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const int N = 1e5 + 5;
ll a[N];
int main()
{
amfetamin;
int n,m;
cin >> n >> m;
for (int i = 0; i < n; i++)
    cin >> a[i];
ll sol = 0;
for (int i = 0; i < m; i++)
{
    int x,y;
    cin >> x >> y;
    x--, y--;

    x = a[x];
    y = a[y];
    if (x > y)
        swap(x, y);
    if (x >= 0 && y >= 0)
        sol += x + y;
    if (x < 0 && y < 0)
        sol -= x + y;
    if (x < 0 && y >= 0)
    {
        x = abs(x);
        sol += max(x - y, y - x);
    }
}
cout << sol;

}