#include <iostream>

using namespace std;

int main() {
    int n, m, x, y;
    long long z1, z2, res = 0;
    
    cin >> n >> m;
    
    int a[n];
    
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    
    for (int i = 0; i < m; ++i) {
        cin >> x >> y;
        
        z1 = -a[x - 1] + -a[y - 1];
        z2 = a[x - 1] + a[y - 1];
        
        res += max(z1, z2);
        
    }
    
    cout << res;
}