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 pair<int, int> P;
constexpr int IINF = INT_MAX;

vector<vector<int> > g, h;
vector<P> es;
vector<int> w, ww, deg, id;
vector<bool> in_cycle;

void dfs(int v){
    in_cycle[v] = false;
    for(auto u : g[v]){
        if(!in_cycle[u]) continue;
        deg[v]--;
        deg[u]--;
        if(deg[u]==1){
            dfs(u);
        }
    }
}

int rec(int v, int p){
    int res = 0;
    for(auto u : h[v]){
        if(u==p) continue;
        res = max(res, rec(u, v));
    }
    return res + ww[v];
}

int main() {
    int n, m;
    cin >> n >> m;
    g.resize(n);
    w.resize(n);
    deg.resize(n, 0);
    id.resize(n);
    in_cycle.resize(n, true);
    for(int i=0;i<n;i++){
        cin >> w[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);
        deg[u]++;
        deg[v]++;
        es.push_back(P(u,v));
    }
    // 根は葉の頂点としない
    // 0 -> cycle -> 0 は必ず移動できる
    deg[0] = IINF;
    // 次数1の頂点から削る
    for(int i=1;i<n;i++){
        if(deg[i]==1){
            dfs(i);
        }
    }
    // 自由に行き来できる頂点を縮約したグラフを構築
    int num = 1;
    ww.push_back(0);
    for(int i=0;i<n;i++){
        if(in_cycle[i]){
            id[i] = 0;
            ww[0] += w[i];
        }
        else{
            id[i] = num++;
            ww.push_back(w[i]);
        }
    }
    h.resize(num);
    for(auto &e : es){
        int u = e.first, v = e.second;
        if(id[u]==id[v]) continue;
        h[id[u]].push_back(id[v]);
        h[id[v]].push_back(id[u]);
    }
    for(int i=0;i<num;i++){
        sort(h[i].begin(), h[i].end());
        h[i].erase(unique(h[i].begin(),h[i].end()),h[i].end());
    }
    // 構築したグラフは木になるので再帰で解ける
    cout << rec(id[0], -1) << endl;

    return 0;
}