#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct list
{
	long long int ind;
	struct list *next;
};

struct poznanstva
{
	long long int brp;
	long long int brn;
	struct list *L;
};

void povezi(struct poznanstva P[], long long int x, long long int y)
{
	struct list *node=(struct list *)malloc(sizeof(struct list));
	node->ind=y;
	node->next=P[x].L;
	P[x].L=node;
	
	struct list *node2=(struct list *)malloc(sizeof(struct list));
	node2->ind=x;
	node2->next=P[y].L;
	P[y].L=node2;
}

main()
{
	long long int N,M,i,a[100001],X[100001],Y[100001],j,Sum=0,prosao;             
	struct poznanstva P[100001];
	scanf("%lld%lld",&N,&M);
	
	for(i=0;i<N;i++)
	scanf("%lld",&a[i]);
	
	for(i=0;i<M;i++)
	scanf("%lld%lld",&X[i],&Y[i]);
	
	for(i=0;i<M;i++)
	{
		P[i].brp=0;
		P[i].brn=0;
		P[i].L=NULL;
	}
	
	for(i=0;i<M;i++)
	povezi(P,X[i]-1,Y[i]-1);
	
	for(i=0;i<N;i++)
	{
		while(P[i].L!=NULL)
		{
			prosao=0;
			j=P[i].L->ind;
			
			if(a[i]>=0 && a[j]>=0 && prosao==0)
			{
			P[i].brp++;
			prosao=1;
			}
			
			if(a[i]<0 && a[j]<0 && prosao==0)
			{
			P[i].brn++;
			prosao=1;
			}
			
			if(a[i]>=0 && a[j]<=0 && prosao==0)
			{
				if(abs(a[i])>=abs(a[j]))
				P[i].brp++;
				
				if(abs(a[i])<abs(a[j]))
				P[i].brn++;
				
				prosao=1;
			}
			
			/*if(a[i]<=0 && a[j]>=0 && prosao==0)
			{
				if(abs(a[i])>=abs(a[j]))
				P[i].brn++;
				
				if(abs(a[i])<abs(a[j]))
				P[i].brp++;
				
				prosao=1;
			}
			*/
			P[i].L=P[i].L->next;
		}
		Sum=Sum+(a[i]*(P[i].brp-P[i].brn));
	}
	printf("%lld",Sum);
}