#include <iostream>

using namespace std;

int main()
{
    int n, m, x, y, zb;
    int sreca = 0;
    
    cin >> n >> m;
    int druz[n];
    
    for(int i = 0; i < n; i++)
    {
        cin >> druz[i];
    }
    
    for(int 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;
}