var
  i,j,m,n,max,ukupnasreca:integer;
  A,X,Y,R:array [1..100000] of integer;

begin
  readln(n,m);
  for i:=1 to n do readln(A[i]);
  for i:=1 to m do readln(X[i],Y[i]);
  max:=0;
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      if X[j]=i then R[i]:=R[i]+1 else if Y[j]=i then R[i]:=R[i]+1;
      if r[i]>max then max:=r[i];
    end;
  end;
  ukupnasreca:=0;
  if a[max]>0 then
  begin
    for i:=1 to n do ukupnasreca:=ukupnasreca+a[i]*r[i]
  end
  else for i:=1 to n do ukupnasreca:=ukupnasreca-a[i]*r[i];
  writeln(ukupnasreca);
  readln;
end.