vars:array[1..1000,1..2] of longint;f:array[1..1000,1..1000] of boolean;a:array[1..1000] of boolean;n,m:longint;
functionmax(x,y:longint):longint;
beginif x>y thenexit(x)elseexit(y);
end;
procedurexxoo(x:longint);vari:longint;
beginfor i:=1to n dobeginif (f[x,i])and(a[i]) thenbegina[i]:=false;xxoo(i);s[x,1]:=s[x,1]+s[i,0];s[x,0]:=s[x,0]+max(s[i,1],s[i,0]);end;end;
end;
vari,ans,x,y:longint;
beginreadln(n,m);for i:=1to n dobeginreadln(s[i,1]);end;for i:=1to m dobeginreadln(x,y);f[x,y]:=true;f[y,x]:=true;end;fillchar(a,sizeof(a),true);for i:=1to n doif a[i] thenbegina[i]:=false;xxoo(i);ans:=ans+max(s[i,1],s[i,0]);end;writeln(ans);
end.