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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long rezrez=0,a1,a2;
    int n,m,g,d;
    cin>>n>>m;
    vector<long long> x;
    vector<long long> y;
    for(int i=0;i<n;i++)
    {
        cin>>g;
        x.push_back(g);
    }
    for(int i=0;i<2*m;i+=2)
    {
        cin>>g>>d;
        g--;
        d--;
        y.push_back(g);
        y.push_back(d);
    }
    for(int i=0;i<=m;i+=2)
    {
        a1=y[i];
        a2=y[i+1];
        if(rezrez+x[a1]+x[a2]>=rezrez-x[a1]-x[a2])
        {
         rezrez=rezrez+x[a1]+x[a2];
        }
        else
        {
         rezrez=rezrez-x[a1]-x[a2];
        }

    }

    cout<<rezrez;

    return 0;
}