#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
int n,m,a[100],x[100][100],p,q,v,w,y[100],r;
stack<int>S;
void dfs(){
for(int i=1;i<=n;i++){
if(y[i]==0){
if(S.size()>=1){
if(x[S.top()][i]==0){goto E;}
}
S.push(i);
y[S.top()]=1;
v+=a[S.top()];
w=max(v,w);
r++;
dfs();
}
E:;
}
if(S.size()>=1){
v-=a[S.top()];
y[S.top()]=0;
S.pop();
r--;
}
return;
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=m;i++){
cin>>p>>q;
x[p][q]=1;
x[q][p]=1;
}
dfs();
cout<<w<<endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8c3RhY2s+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbixtLGFbMTAwXSx4WzEwMF1bMTAwXSxwLHEsdix3LHlbMTAwXSxyOwpzdGFjazxpbnQ+UzsKCnZvaWQgZGZzKCl7Cglmb3IoaW50IGk9MTtpPD1uO2krKyl7CgkJaWYoeVtpXT09MCl7CgkJCWlmKFMuc2l6ZSgpPj0xKXsKCQkJCWlmKHhbUy50b3AoKV1baV09PTApe2dvdG8gRTt9CgkJCX0KCQkJUy5wdXNoKGkpOwoJCQl5W1MudG9wKCldPTE7CgkJCXYrPWFbUy50b3AoKV07CgkJCXc9bWF4KHYsdyk7CgkJCXIrKzsKCQkJZGZzKCk7CgkJfQoJCUU6OwoJfQoJaWYoUy5zaXplKCk+PTEpewoJCXYtPWFbUy50b3AoKV07CgkJeVtTLnRvcCgpXT0wOwoJCVMucG9wKCk7CgkJci0tOwoJfQoJcmV0dXJuOwp9CgppbnQgbWFpbigpewoJY2luPj5uPj5tOwoJZm9yKGludCBpPTE7aTw9bjtpKyspewoJCWNpbj4+YVtpXTsKCX0KCWZvcihpbnQgaT0xO2k8PW07aSsrKXsKCQljaW4+PnA+PnE7CgkJeFtwXVtxXT0xOwoJCXhbcV1bcF09MTsKCX0KCWRmcygpOwoJY291dDw8dzw8ZW5kbDsKCXJldHVybiAwOwp9