#include <iostream>
using namespace std;
int main()
{
    int n, m;
    cin>>n>>m;
    int a[n];
    for(int i = 0; i<n; i++)
        cin>>a[i];
    int s = 0;
    for(int i = 0; i<m; i++)
    {
        int x,y;
        cin>>x>>y;
        int p = a[x-1]+a[y-1];
        int q = (-a[x-1])+(-a[y-1]);
        s+= max(p,q);
    }
    cout<<s;
    return 0;
}