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 ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> edge;

vector<vi> G;

void bridge_dfs(int now, int from, vector<edge> &bridge, vector<vi> &bicomp, stack<int> &roots,
                stack<int> &S, vb &inS, vi &preord, int &pre_ct){
    preord[now] = pre_ct++;
    S.push(now); inS[now]=true;
    roots.push(now);
    rep(i,G[now].size()){
        int to = G[now][i];
        if(preord[to] == -1) bridge_dfs(to,now,bridge,bicomp,roots,S,inS,preord,pre_ct);
        else if(from != to && inS[to]) while(preord[roots.top()] > preord[to]) roots.pop();
    }
    if(now == roots.top()){
        bridge.pb(edge(now,from));
        bicomp.pb(vi());
        while(1){
            int v=S.top(); S.pop(); inS[v]=false;
            bicomp.back().pb(v);
            if(now == v) break;
        }
        roots.pop();
    }
}

void bridge_detect(vector<edge> &bridge, vector<vi> &bicomp){
    const int n=G.size();
    vi preord(n,-1);
    vb inS(n,false);
    stack<int> roots,S;
    int pre_ct=0;
    rep(i,n)if(preord[i] == -1){
        bridge_dfs(i,n,bridge,bicomp,roots,S,inS,preord,pre_ct);
        bridge.pop_back();
    }
}

vector<vi> T;
vi par;
vb leaf;
void dfs(int v, int p){
    par[v] = p;
    for(int e:T[v])if(e!=p){
        dfs(e,v);
        leaf[v] = false;
    }
}

int main(){
    int n,m;
    scanf(" %d %d", &n, &m);
    vector<int> w(n);
    rep(i,n) scanf(" %d", &w[i]);
    vector<int> a(m),b(m);
    rep(i,m){
        scanf(" %d %d", &a[i], &b[i]);
        --a[i];
        --b[i];
    }

    G = vector<vi>(n);
    rep(i,m){
        G[a[i]].pb(b[i]);
        G[b[i]].pb(a[i]);
    }

    vector<edge> bridge;
    vector<vi> bicomp;
    bridge_detect(bridge, bicomp);

    int sz = bicomp.size();

    vector<int> cmp(n);
    rep(i,sz){
        for(int j:bicomp[i]) cmp[j] = i;
    }

    T = vector<vi>(sz);
    rep(i,m){
        int u = cmp[a[i]], v = cmp[b[i]];
        if(u!=v){
            T[u].pb(v);
            T[v].pb(u);
        }
    }

    int root = cmp[0];
    par = vi(sz,-1);
    leaf = vb(sz,true);
    dfs(root,-1);

    vector<bool> ok(sz);
    queue<int> que;
    rep(i,sz){
        if(bicomp[i].size()>1){
            ok[i] = true;
            que.push(i);
        }
    }
    while(!que.empty()){
        int now = que.front();
        que.pop();

        int pp = par[now];
        if(pp==-1) continue;

        if(!ok[pp]){
            ok[pp] = true;
            que.push(pp);
        }
    }

    int ans = 0;
    rep(i,sz){
        if(!ok[i] && leaf[i]){
            int tmp = 0;
            int idx = i;
            while(idx!=-1 && !ok[idx]){
                tmp += w[bicomp[idx][0]];
                idx = par[idx];
            }

            ans = max(ans, tmp);
        }
    }

    rep(i,sz)if(ok[i]){
        for(int j:bicomp[i]) ans += w[j];
    }

    cout << ans << endl;
    return 0;
}