#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//17:00~
class nizyu{public:
	//2重辺連結成分分解ライブラリ!!!!!!!
	//SCCみたいにつかいます
	vector<vector<int>>road;//もとの辺
	vector<int>imo;
	vector<int>name;
	vector<bool>used;//訪れた順 こう大変を知ることができる
	vector<bool>uuuu;
	int n,niznum;//niznum=連結成分全体のかず
	nizyu(void){}
	nizyu(int in){n=in;road.res(n);}
	void add_road(int a,int b){road[a].pub(b);road[b].pub(a);}
	void sai_dfs(int ter,int oya){
		name[ter]=niznum;
		//cerr<<"name["<<ter<<"]="<<niznum<<endl;
		for(auto it:road[ter]){
			if(it==oya){continue;}
			if(name[it]!=-1){continue;}
			sai_dfs(it,ter);
		}
	}
	int dfs_tree(int ter,int oya=-1){
		//cerr<<"ter="<<ter<<"oya="<<oya<<endl;
		//dfs木を作る
		if(used[ter]){return 0;}
		used[ter]=true;
		int koutai=0;
		bool che=true;
		for(auto it:road[ter]){
			if(it==oya&&che){che=false;continue;}//一度だけ無効化(来た道なので)
			if(used[it]&&(!uuuu[it])){koutai++;imo[it]++;}
			else{koutai+=dfs_tree(it,ter);}
		}
		koutai-=imo[ter];
		//cerr<<"ter="<<ter<<"koutai="<<koutai<<endl;
		uuuu[ter]=true;
		if(koutai==0){sai_dfs(ter,oya);niznum++;}//橋
		return koutai;
	}
	void do_nizyu(void){
		//二十辺連結成分分解する
		niznum=0;
		imo.res(n);
		used.res(n);
		uuuu.res(n);
		name.res(n);for(auto &it:name){it=-1;}
		for(int i=0;i<n;i++){dfs_tree(i);}
		//for(auto it:name){cerr<<"name="<<it<<endl;}
	}
	vector<vector<int>>Croad;//新しいみち
	void chain_niz(void){
		do_nizyu();
		Croad.res(niznum);
		for(int i=0;i<n;i++){
			for(auto it:road[i]){Croad[name[i]].pub(name[it]);}
		}
		for(int i=0;i<niznum;i++){
			sort(Croad[i].begin(),Croad[i].end());
			Croad[i].erase(unique(Croad[i].begin(),Croad[i].end()),Croad[i].end());
			auto itr=find(Croad[i].begin(),Croad[i].end(),i);
			if(itr!=Croad[i].end()){Croad[i].erase(itr);}
		}
	}
};
vector<llint>val;
llint ans=0;
llint solve(nizyu&in,int ter,int per){
	llint dp=0;
	for(auto it:in.Croad[ter]){
		if(it==per){continue;}
		llint gen=solve(in,it,ter);
		maxeq(ans,dp+gen+val[ter]);
		maxeq(dp,gen);
	}
	dp+=val[ter];
	maxeq(ans,dp);
	return dp;
}
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int i,j,n,m;cin>>n>>m;
	vector<llint>valm(n);
	for(i=0;i<n;i++){cin>>valm[i];}
	nizyu gra(n);
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;a--;b--;
		gra.add_road(a,b);
	}
	gra.chain_niz();
	int c=gra.niznum;
	val.res(c);
	for(i=0;i<n;i++){val[gra.name[i]]+=valm[i];}
	solve(gra,0,-1);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 24008