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>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>e[100005];
vector<int>edge[100005];
int used[100005];
int w[100005],k;
vector<int>E[100005];
ll W[100005];
int in[100005];
ll dp[100005];
int cnt[100005],c[100005];
int par[100005],ran[100005];
ll ans,add;
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
void dfs(int v,int u,int d){
	used[v] = d;//cout << v << endl;
	for(int i=0;i<e[v].size();i++){
		if(e[v][i] == u) continue;
		if(used[e[v][i]] && used[e[v][i]] < used[v]){
			cnt[e[v][i]]--;
			cnt[v]++;
			unite(e[v][i],v);
			//cout << v << " " << e[v][i] << endl;
			continue;
		}
		else if(used[e[v][i]]) continue;
		dfs(e[v][i],v,d+1); edge[v].pb(e[v][i]);edge[e[v][i]].pb(v); //cout << v << " " << e[v][i] << endl;
	}
}
int dfs2(int v,int u){
	int sum = 0;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		int a = dfs2(edge[v][i],v);
		if(a>0){
		    //cout << edge[v][i] << " f" << v << endl;
			unite(edge[v][i],v);
		}
		sum += a;
	}
	sum += cnt[v];
	return sum;
}
pair<ll,bool> dfs3(int v,int p){
	ll ret = 0; bool ok = (c[v] >= 3);
	for(int i=0;i<E[v].size();i++){
		if(E[v][i] == p) continue;
		pair<ll,bool> t = dfs3(E[v][i],v);
		ret = max(ret,t.fi);
		ok |= t.sc;
	}
	if(ok){
		ret = 0;
		ans += W[v];
		//cout << v << endl;
	}
	else ret += W[v];
	add = max(add,ret);
	return mp(ret,ok);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d",&w[i]);
	for(int i=0;i<m;i++){
		int a,b; scanf("%d%d",&a,&b); a--; b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	init(); dfs(0,-1,1); dfs2(0,-1);
	for(int i=0;i<n;i++){
		W[find(i)] += w[i];
		c[find(i)] ++;
		for(int j=0;j<e[i].size();j++){
			if(find(i) != find(e[i][j])){
				E[find(i)].pb(find(e[i][j]));
				E[find(e[i][j])].pb(find(i));
			}
		}
	}
	for(int i=0;i<n;i++){
		SORT(E[i]); ERASE(E[i]);
	}
	dfs3(find(0),-1);
	cout << ans+add << endl;
}