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;

struct twoEdgeComponents {
	int n;
	vector<vector<int>> g;
	vector<int> cmp;
	vector<vector<int>> each_bcc;
	vector<pair<int,int>> bridge;
	vector<int> order;
	vector<bool> inS;
	stack<int> roots, S;

	twoEdgeComponents() {}
	twoEdgeComponents(vector<vector<int>> g_) : n(g_.size()), g(g_) {}

	void add_edge(int p, int q) {
		g[p].push_back(q);
		g[q].push_back(p);
	}

	void dfs(int cur, int prev, int &k) {
		order[cur] = ++k;
		S.push(cur); inS[cur] = true;
		roots.push(cur);

		for(auto to: g[cur]) {
			if(order[to]==0) dfs(to, cur, k);
			else if(to!=prev && inS[to]) {
				while(order[roots.top()] > order[to]) roots.pop();
			}
		}

		if(cur == roots.top()) {
			if(prev!=-1) bridge.push_back({prev, cur});
			vector<int> bcc;
			while(1) {
				int node = S.top(); S.pop(); inS[node] = false;
				bcc.push_back(node);
				if(node==cur) break;
			}
			each_bcc.push_back(bcc);
			roots.pop();
		}
	}

	void bcc() {
		order.assign(n, 0);
		inS.assign(n, false);
		cmp.assign(n, -1);
		int k = 0;
		for(int i=0; i<n; ++i) {
			if(order[i] == 0) {
				dfs(i, -1, k);
			}
		}
		for(int i=0; i<(int)each_bcc.size(); ++i) {
			for(auto j: each_bcc[i]) {
				cmp[j] = i;
			}
		}
	}

	vector<vector<int>> getbcc() {
		vector<vector<int>> h(each_bcc.size(), vector<int>());
		for(auto i: bridge) {
			int a = cmp[i.first], b = cmp[i.second];
			h[a].push_back(b);
			h[b].push_back(a);
		}
		return h;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> w(n);
	for(int i=0; i<n; ++i) cin >> w[i];
	vector<vector<int>> g(n);
	for(int i=0; i<m; ++i) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	twoEdgeComponents graph(g);
	graph.bcc();
	// for(auto i: graph.bridge) cout << i.first << "," << i.second << endl;
	// cout << "-----" << endl;
	// for(auto i: graph.each_bcc) {
	// 	for(auto j: i) {
	// 		cout << j << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << "-----" << endl;
	vector<vector<int>> tree = graph.getbcc();
	// for(auto i: tree) {
	// 	for(auto j: i) {
	// 		cout << j << " ";
	// 	}
	// 	cout << endl;
	// }

	vector<int> W(graph.each_bcc.size());
	for(int i=0; i<(int)graph.each_bcc.size(); ++i) {
		for(int j=0; j<(int)graph.each_bcc[i].size(); ++j) {
			W[i] += w[graph.each_bcc[i][j]];
		}
	}

	vector<bool> v(n, false);
	function<bool(int,int)> dfs = [&](int x, int p) {
		bool ret = false;
		if(graph.each_bcc[x].size() >= 2) ret = true;
		for(auto i: tree[x]) {
			if(i == p) continue;
			ret |= dfs(i, x);
		}
		// cout << x << " " << ret << endl;
		return v[x] = ret;
	};

	dfs(graph.cmp[0], -1);

	int ans = 0;
	for(int i=0; i<(int)graph.each_bcc.size(); ++i) {
		if(v[i]) ans += W[i];
	}
	// cout << ans << endl;

	int tmp = 0;
	vector<int> v2(n, 0);
	function<void(int,int,int)> dfs2 = [&](int x, int p, int cost) {
		if(!v[x]) cost += W[x];
		tmp = max(tmp, cost);
		for(auto i: tree[x]) {
			if(i == p) continue;
			dfs2(i, x, cost);
		}
	};

	dfs2(graph.cmp[0], -1, 0);
	ans += tmp;
	cout << ans << endl;

	return 0;
}