#include <iostream>

using namespace std;

int main()
{
    long long n, m, x, y, zb;
    long long sreca = 0;
    
    cin >> n >> m;
    long long druz[n];
    
    for(long long i = 0; i < n; i++)
    {
        cin >> druz[i];
    }
    
    for(long long i = 0; i < m; i++)
    {
        cin >> x >> y;
        
        zb = druz[x - 1] + druz[y - 1];
        
        if((sreca + zb) > (sreca - zb))
        {
            sreca += zb;
        }
        else
        {
            sreca -= zb;
        }
    }
    
    cout << sreca;
    
    return 0;
}