program Prijatelji;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };
  var n, m, i, b, c, z: longint;
      a: array[1..100000] of longint;
      x, y: array[1..100000] of longint;
begin
  read(n, m);
  for i:=1 to n do
    begin
      readln(a[i]);
      x[i]:=0;
      y[i]:=0;
    end;
  for i:=1 to m do
    begin
      read(b);
      read(c);
      if ((a[b]<0) and (-a[b]>a[c])) or ((a[c]<0) and (-a[c]>a[b])) then
        begin
          y[b]:=y[b]+1;
          y[c]:=y[c]+1;
        end
      else
        begin
          x[b]:=x[b]+1;
          x[c]:=x[c]+1;
        end;
    end;
  z:=0;
  for i:=1 to n do z:=z+a[i]*(x[i]-y[i]);
  writeln(z);
end.