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;

using Weight=int;

struct Edge{
    int src,dst;
    Edge(int src,int dst):
    src(src),dst(dst){}
};

using Edges=vector<Edge>;
using Graph=vector<Edges>;

int memo[100001];

pair<vector<int>, Edges> bridge(const Graph& g) {
	const int n = g.size();
	int idx = 0, s = 0, t = 0, k = 0;
	vector<int>ord(n, -1), onS(n), stk(n), roots(n), cmp(n);
	Edges brdg;
	function<void(int, int)> dfs = [&](int v, int u) {
		ord[v] = idx++;
		stk[s++] = v;
		onS[v] = true;
		roots[t++] = v;
		for (auto& e : g[v]) {
			int w = e.dst;
			if (ord[w] == -1)dfs(w, v);
			else if (u != w && onS[w])
				while (ord[roots[t - 1]]>ord[w])--t;
		}
		if (v == roots[t - 1]) {
			brdg.emplace_back(u, v);
			while (true) {
				int w = stk[--s];
				onS[w] = false;
				cmp[w] = k;
				if (v == w)break;
			}
			--t;
			++k;
		}
	};
	for (int u = 0; u<n; ++u) {
		if (ord[u] == -1) {
			dfs(u, n);
			brdg.pop_back();
		}
	}
	return make_pair(cmp, brdg);
}

bool dfs0(const Graph &g,int p,int v,vector<bool> &elect,
vector<int>&elements,vector<int>&cycle){
    for(auto e:g[v]){
        if(e.dst==p)continue;
        if(elements[cycle[e.dst]]>1 || elect[e.dst])return elect[v]=1;
        if(dfs0(g,v,e.dst,elect,elements,cycle))return elect[v]=1;
    }
    return 0;
}

int dfs1(const Graph &g,int p,int v,vector<bool> &elect,
vector<int>&elements,vector<int>&cycle,vector<Weight>&node){
    if(memo[v])return memo[v];
    int res=0;
    for(auto e:g[v]){
        if(elect[e.dst]){
            return memo[v]=node[v];
        }
        if(e.dst!=p && elements[cycle[e.dst]]==1){
            res=dfs1(g,v,e.dst,elect,elements,cycle,node);
            if(res){
                return memo[v]=res+node[v];
            }
        }
    }
    return 0;
}

int main(){
    int n,m;
    cin>>n>>m;
    Graph g(n);
    vector<Weight>node(n);
    for(int i=0;i<n;++i){
        cin>>node[i];
    }
    for(int i=0;i<m;++i){
        int s,t;
        cin>>s>>t;
        --s;--t;
        g[s].emplace_back(s,t);
        g[t].emplace_back(t,s);
    }
    vector<int>cycle = bridge(g).first;
    vector<int>elements(n,0);
    for(int i=0;i<n;++i){
        elements[cycle[i]]++;
    }
    vector<bool>elect(n,false);
    elect[0]=true;
    for(int i=1;i<n;++i){
        if(elements[cycle[i]]>1){
            dfs0(g,-1,i,elect,elements,cycle);
        }
    }
    int buf=0;
    for(int i=1;i<n;++i){
        if(g[i].size()==1){
            buf=max(buf,dfs1(g,-1,g[i][0].src,elect,elements,cycle,node));
        }
    }
    int ans=0;
    for(int i=0;i<n;++i){
        if(elect[i]){
            ans+=node[i];
        }
    }
    ans+=buf;
    cout<<ans<<endl;
    return 0;
}