#include <bits/stdc++.h>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    unsigned int N,M;
    long long suma=0;
    cin >> N >>M;

    vector <int> druzeljubivost(N);
    vector <vector <int>> poznanici (N);
     unsigned int br_nedruzeljubivih=0;

    for (unsigned int i=0;i<N;i++)
         {cin >> druzeljubivost[i];
          if (druzeljubivost[i]<0)
            br_nedruzeljubivih++;
         }


    for (unsigned int i = 0; i < M; i++) {
       int a, b;
       cin >> a >> b; a--; b--;
       poznanici[a].push_back(b);
       poznanici[b].push_back(a);
      }

      //cout << "ISPIS UCITANOG" <<endl;
      //      cout << "Nedruzeljubivih: " <<br_nedruzeljubivih<<endl;

     //for (unsigned int i=0;i<N;i++)
      //   {cout <<"Druzeljubivost: "<<druzeljubivost[i];;
        //  cout <<"  Poznanika: "<<poznanici[i].size() <<endl;
         //}


    if (br_nedruzeljubivih%2==0)
      {for (unsigned int i=0;i<N;i++)
          suma+= druzeljubivost[i]*(poznanici[i].size());
      }
    else
       {for (unsigned int i=0;i<N;i++)
          {
           // cout <<suma<<endl;
            int pom1=druzeljubivost[i];
            int pom2=poznanici[i].size();
            suma+= ((-1)*pom1*pom2);
           // cout <<suma<<endl;
          }
                }
    cout << suma <<"\n";

    return 0;
}