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 <iostream>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

class BECC{
private:
    int N;
    vector<vector<int>> G;
    vector<int> order,inS;
    stack<int> S,roots;
    vector<int> cmp;
public:
    vector<P> bridge;
    vector<vector<int>> bccs;
    vector<vector<int>> dcmp;//分解後のグラフ
    BECC(int n,vector<vector<int>> graph){
        N = n;
        G = graph;
        order = inS = cmp = vector<int>(N+1,0);
    }
    void dfs(int cur,int prev,int k){
        order[cur] = ++k; //訪問順に番号付け
        S.push(cur); inS[cur] = true;//訪問した頂点の集合に追加
        roots.push(cur);//各bccの根を管理
        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();//(to,cur]を捨てる
            }
        }
        if(cur==roots.top()){
            if(prev!=-1) bridge.emplace_back(prev,cur);//根でないなら橋になる
            vector<int> bcc;
            while(true){
                int node = S.top(); S.pop(); inS[node] = false;//nodeを捨てる
                bcc.emplace_back(node);//nodeをbccに追加
                cmp[node] = bccs.size();
                if(node==cur) break;
            }
            bccs.emplace_back(bcc);
            roots.pop();
        }
    }
    int find(int n){return cmp[n];}
    int cmp_size(int n){return bccs[cmp[n]].size();}
    int size(int n){return bccs[n].size();}
    void decomposition(){
        int k = 0;
        bccs.push_back(vector<int>{});
        for(int i=1;i<=N;i++) if(order[i]==0) dfs(i,-1,k);
        dcmp = vector<vector<int>>(bccs.size());
        for(auto x:bridge){
            dcmp[cmp[x.first]].push_back(cmp[x.second]);
            dcmp[cmp[x.second]].push_back(cmp[x.first]);
        }
    }
};

vector<int> dp(100010,0),dp2(100010,0);
vector<int> ok(100010,0);
vector<int> W(100010,0);
vector<int> S(100010,0);
void dfs(int n,int m,BECC& becc){
    int ma = 0;
    ok[n] = (becc.size(n)!=1);
    for(auto x:becc.dcmp[n]){
        if(x!=m){
            dfs(x,n,becc);
            if(ok[x]) dp[n] += dp[x];
            dp2[n] = max(dp2[n],dp2[x]);
            ok[n] = (ok[n] | ok[x]);
        }
    }
    if(!ok[n]) dp2[n] += S[n];
    else dp[n] += S[n];
}
int N,M;
int main(){
    cin >> N >> M;
    for(int i=1;i<=N;i++) cin >> W[i];
    vector<vector<int>> v(N+1);
    int a,b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    BECC becc(N,v);
    becc.decomposition();
    for(int i=1;i<=N;i++){
        S[becc.find(i)] += W[i];
    }
    dfs(becc.find(1),-1,becc);
    cout << dp[becc.find(1)]+dp2[becc.find(1)] << endl;
}