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>
using namespace std;

const int INF = 1e9;

void visit(vector< vector<int> > &G, int cur, int prev, vector< pair<int, int> > &brg, vector< vector<int> > &each_bcc, stack<int> &roots, stack<int> &S, vector<bool> &inS, vector<int> &order, int &k){
  order[cur] = ++k;
  S.push(cur);
  inS[cur] = true;
  roots.push(cur);
  for(int i = 0; i < G[cur].size(); ++i){
    int to = G[cur][i];
    if(!order[to]) visit(G, to, cur, brg, each_bcc, roots, S, inS, order, k);
    else if(to != prev && inS[to]){
      while(order[roots.top()] > order[to]) roots.pop();
    }
  }

  if(cur == roots.top()){
    if(prev != -1) brg.push_back(pair<int, int>(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 bridge(vector< vector<int> > &G, vector< pair<int, int> > &brg, vector< vector<int> > &each_bcc){
  int V = G.size();
  vector<int> order(V);
  vector<bool> inS(V);
  stack<int> roots, S;
  int k = 0;
  for(int i = 0; i < V; ++i){
    if(!order[i]) visit(G, i, -1, brg, each_bcc, roots, S, inS, order, k);
  }
}

void dfs(vector< vector<int> > &G, vector<int> &D, int s){
  for(int i = 0; i < G[s].size(); ++i){
    int v = G[s][i];
    if(D[v] > D[s] + 1){
      D[v] = D[s] + 1;
      dfs(G, D, v);
    }
  }
}

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 u, v;
    cin >> u >> v;
    --u;--v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  vector< vector<int> > each_bcc;
  vector< pair<int, int> > brg;
  bridge(G, brg, each_bcc);
  int V = each_bcc.size();
  vector<int> W_(V, 0), cmp(N);

  for(int i = 0; i < V; ++i){
    for(int j = 0; j < each_bcc[i].size(); ++j){
      cmp[each_bcc[i][j]] = i;
      W_[i] += W[each_bcc[i][j]];
    }
  }

  vector< vector<int> > G_(V);
  for(int i = 0; i < brg.size(); ++i){
    int u = brg[i].first, v = brg[i].second;
    G_[cmp[u]].push_back(cmp[v]);
    G_[cmp[v]].push_back(cmp[u]);
  }
  vector<int> D(V, INF);
  D[cmp[0]] = 0;
  dfs(G_, D, cmp[0]);
  int ans = 0;
  vector<int> R;
  for(int i = 0; i < V; ++i){
    if(G_[i].size() > 1 || i == cmp[0]) continue;
    int v = i;
    while(each_bcc[v].size() < 3 && v != cmp[0]){
      for(int j = 0; j < G_[v].size(); ++j){
        int u = G_[v][j];
        if(D[u] == D[v] - 1){
          v = u;
          break;
        }
      }
    }
    if(v != cmp[0]) R.push_back(v);
  }

  ans += W_[cmp[0]];
  vector<bool> visited(V, false);
  visited[cmp[0]] = true;
  for(int i = 0; i < R.size(); ++i){
    int v = R[i];
    while(!visited[v]){
      ans += W_[v];
      visited[v] = true;
      for(int j = 0; j < G_[v].size(); ++j){
        int u = G_[v][j];
        if(D[u] == D[v] - 1){
          v = u;
          break;
        }
      }
    }
  }
  int s = 0;
  for(int i = 0; i < V; ++i){
    if(G_[i].size() > 1 || visited[i]) continue;
    int v = i, t = 0;
    while(!visited[v]){
      t += W_[v];
      for(int j = 0; j < G_[v].size(); ++j){
        int u = G_[v][j];
        if(D[u] == D[v] - 1){
          v = u;
          break;
        }
      }
    }
    s = max(s, t);
  }
  ans += s;
  cout << ans << endl;

  return 0;
}