Problem: Escape

An undirected graph with positive values ​​at the vertices is given. The vertices are numbered from 1 to N, and the i-th vertex has a value of w_i. You can start from the first vertex and move on the graph with the constraint that you cannot pass the edge that you just passed. At each vertex, you can get the score of the value that the vertex has only when you visit it for the first time.

Find the maximum sum of the points you can get.

Constraints

* 1 ≤ N ≤ 100000
* N − 1 ≤ M ≤ 100000
* 1 ≤ w_i ≤ 1000
* 1 ≤ u_i, v_i ≤ N
* There are no multiple edges or self edges
* The graph is concatenated



Input Format

Input is given from standard input in the following format.


N M
w_1 w_2 ... w_N
u_1 v_1
u_2 v_2
...
u_M v_M


In the first line, the number of vertices N of the graph and the integer M representing the number of edges are entered.
The value w_i of each vertex is entered in the second line.
In addition, the number of the two vertices connected by each side is entered in the M line.


Output Format

Print the answer on one line.

Sample Input 1


6 6
1 2 3 4 5 6
1 2
twenty three
3 4
14
4 5
5 6


Sample Output 1


twenty one


<image>
You can collect the points of all vertices by going from vertices 1 → 2 → 3 → 4 → 5 → 6.

Sample Input 2


7 8
1 3 3 5 2 2 3
1 2
twenty three
3 1
14
1 7
1 5
1 6
5 6


Sample Output 2


16


<image>
You can collect 16 points by going from vertices 1 → 2 → 3 → 1 → 5 → 6 → 1 → 4.





Example

Input

6 6
1 2 3 4 5 6
1 2
2 3
3 4
1 4
4 5
5 6


Output

21

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vi a,d;
vvi g;

int dfs(int v,int p){
	int mx=0;
	for(auto u:g[v]) if(u!=p) mx=max(mx,dfs(u,v));
	return mx+a[v];
}

bool DFS(int v,int p,vi& b){
	if(v==0){
		b[v]=1;
		return 1;
	}
	for(auto u:g[v]) if(u!=p){
		if(DFS(u,v,b)){
			b[v]=1;
			return 1;
		}
	}
	return 0;
}

int main(){
	cin>>n>>m;
	a=d=vi(n);
	g=vvi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
		d[u]++;d[v]++;
	}
	vi b(n,1);
	queue<int> q;
	for(int i=0;i<n;i++) if(d[i]==1){
		q.push(i);
		b[i]=0;
	}
	while(!q.empty()){
		int v=q.front();
		q.pop();
		for(auto u:g[v]) if(b[u]){
			d[u]--;
			if(d[u]==1){
				q.push(u);
				b[u]=0;
			}
		}
	}
	int sum=0,cnt=0;
	for(int i=0;i<n;i++) if(b[i]) sum+=a[i],cnt++;
	if(sum){
		int N=n-cnt+1;
		vvi G(N);
		vi c(n),A(N);
		int id=1;
		for(int i=0;i<n;i++) if(!b[i]){
			c[i]=id;
			A[id]=a[i];
			id++;
		}
		A[0]=sum;
		for(int u=0;u<n;u++) for(auto v:g[u]) if(c[u]!=c[v]) G[c[u]].push_back(c[v]);
		n=N;
		g=G;
		a=A;
		if(c[0]==0) cout<<dfs(0,-1)<<endl;
		else{
			int res=dfs(c[0],-1);
			b=vi(N);
			DFS(c[0],-1,b);
			sum=0,cnt=0;
			for(int i=0;i<n;i++) if(b[i]) sum+=a[i],cnt++;
			N=n-cnt+1;
			G=vvi(N);
			c=vi(n),A=vi(N);
			id=1;
			for(int i=0;i<n;i++) if(!b[i]){
				c[i]=id;
				A[id]=a[i];
				id++;
			}
			A[0]=sum;
			for(int u=0;u<n;u++) for(auto v:g[u]) if(c[u]!=c[v]) G[c[u]].push_back(c[v]);
			n=N;
			g=G;
			a=A;
			cout<<max(res,dfs(0,-1))<<endl;
		}
	}
	else cout<<dfs(0,-1)<<endl;
}