// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//ESWN
class BRI{
	public:
	int n,N;
	vi order,inS,cmp;
	vp brg;
	vvi G,each_bcc;
	// N : scc後の頂点数
	// brg : 橋一覧
	// each_bcc : 二重連結成分のリスト
	// cmp : ある頂点がどの二重連結成分に含まれているか
	stack<int> roots, S;
	BRI(int size){
		n=size;
		G=vvi(n);
	}
	void add_edge(int s,int t){
		G[s].pb(t);
		G[t].pb(s);
	}
	void visit(int cur,int prev,int &k){
		order[cur]=++k;
		S.push(cur);
		inS[cur]=true;
		roots.push(cur);
		
		rep(i,G[cur].size()){
			int to=G[cur][i];
			if(!order[to])visit(to,cur,k);
			else if(to!=prev&&inS[to])
				while(order[roots.top()]>order[to])roots.pop();
		}
		
		if(cur==roots.top()){
			if(prev!=-1)brg.pb({prev,cur});
			vi bcc;
			while(1){
				int node=S.top();
				S.pop();
				inS[node]=false;
				bcc.pb(node);
				cmp[node]=N;
				if(node==cur)break;
			}
			N++;
			each_bcc.pb(bcc);
			roots.pop();
		}
	}
	void bri(){
		N=0;
		order=inS=cmp=vi(n);
		roots=S=stack<int>();
		int k=0;
		rep(i,n)if(order[i]==0)
			visit(i,-1,k);
	}
	vvi make(){
		vvi tG(N);
		rep(i,brg.size()){
			int a=brg[i].first,b=brg[i].second;
			tG[cmp[a]].pb(cmp[b]);
			tG[cmp[b]].pb(cmp[a]);
		}
		return tG;
	}
	vvi f(vi w){
		vvi out(N,vi(2));
		rep(i,n){
			out[cmp[i]][1]++;
			out[cmp[i]][0]+=w[i];
		}
		return out;
	}
};
vvi data;
int n,m;
vvi G;
vi used;
pii dfs(int a){
	int out1=0,out2=0;
	used[a]=true;
	rep(i,G[a].size())if(used[G[a][i]]==0){
		pii t=dfs(G[a][i]);
		out1=max(out1,t.first);
		out2+=t.second;
	}
	if(out2||data[a][1]-1)out2+=data[a][0];
	else out1+=data[a][0];
	return {out1,out2};
}
int main(){
	cin>>n>>m;
	vi w(n);
	rep(i,n)cin>>w[i];
	BRI bri(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		a--;b--;
		bri.add_edge(a,b);
	}
	bri.bri();
	n=bri.N;
	G=bri.make();
	data=bri.f(w);
	used=vi(n);
	pii ans=dfs(bri.cmp[0]);
	cout<<ans.first+ans.second<<endl;
}

	





Measured memory_bytes: 38372