/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

long long m, n, p1, p2, q;





long long a[100007];
long long znak[100070];

long long sum=0;

int main()
{
    cin>>n>>m;
    
    for(long long i=1;i<=n;i++)
        {cin>>q;
        
        if(q<0)
        {
            a[i]=abs(q); znak[i]=-1;
        }
        
        else if(q>=0) {a[i]=q; znak[i]=1;}      //nije pokriven slucaj q=0
        
            
        }      //druzeljubivost itog
        
        
        
    
    // proveren deo gore radi
    
    for(long long j=1;j<=m;j++)
    {
        cin>>p1>>p2; //pozicije od 1 do n
       
       if(a[p1]>=a[p2]) //znak od p1 ce presuditi, ako je znak - neprijatelji su
        {
           sum=sum+a[p1]*znak[p1]*znak[p1]+a[p2]*znak[p2]*znak[p1];
           
        }
        
          if(a[p2]>a[p1])
          {
              sum=sum+a[p2]*znak[p2]*znak[p2]+znak[p2]*znak[p1]*a[p1];
          }
       }
       
    cout<<sum;
    
    
        
        

        
        
}