#include <iostream>

using namespace std;

int main()
{
    int p = 1;
    int m, n;
    cin >> n >> m;
    long long int druzeljubivost[n];
    for (int i = 0; i < n; i++) {
        cin >> druzeljubivost[i];
        if (druzeljubivost[i] != 1) {
            p = -1;
            for (int i = 0; i < n; i++) {
                if (druzeljubivost[i] > 1) {
                    p = 0;
                    for (int i = 0; i < n; i++) {
                        if (druzeljubivost[i] < 0) {
                            p = 3;
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
    int parovi[m][2];
    for (int i = 0; i < m; i++) {
        cin >> parovi[i][0] >> parovi[i][1];
    }
    int niz[n];
    for (int i = 0; i < n; i++) {
        niz[i] = 0;
    }
    for (int b = 0; b < 2; b++) {
        for (int j = 0; j < m; j++) {
            niz[parovi[j][b] - 1]++;
        }
    }
    long long sreca = 0;
    if (p == 1) {
        for (int i = 0; i < n; i++) {
            sreca = sreca + niz[i];
        }
        cout << sreca;
    }
    else if (p == -1) {
        for (int i = 0; i < n; i++) {
            sreca = sreca + druzeljubivost[i] * niz[i];
        }
        cout << -sreca;
    }
    else if (p == 0) {
        for (int i = 0; i < n; i++) {
            sreca = sreca + druzeljubivost[i] * niz[i];
        }
        cout << sreca;
        
    }
    else {
        cout << 3;
    }
}