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;

#define rep(i,n) for(int i=0;i<(int)n;i++)

class Graph{
public:
  int n;
  vector<vector<int> > e;
  vector<int> w,vdeg,cost;

  Graph(int v){
    n = v;
    w = vector<int>(n,0);
    vdeg = vector<int>(n,0);
    cost = vector<int>(n,0);
    e = vector<vector<int> >(n,vector<int>(0));
  }

  void addEdge(int a, int b){
    e[a].push_back(b);
    e[b].push_back(a);
    vdeg[a]++;
    vdeg[b]++;
  }

  int degree(int u){
    return (int)e[u].size();
  }

  bool isConnected(int u, int v){
    auto itr = find(e[u].begin(),e[u].end(),v);
    if(itr == e[u].end()) return false;
    return true;
  }

};

class Tree{
public:
  int n,mc=0;
  vector<int> par,w,cost;
  vector<vector<int> > child;

  Tree(int v){
    n = v;
    par = vector<int>(n,-1);
    w = vector<int>(n,0);
    cost = vector<int>(n,0);
    child = vector<vector<int> >(n,vector<int>(0));
  }

  void setCost(int v, int c){
    cost[v] = c;
    mc = max(mc,c);
  }

  void addCost(int v, int c){
    cost[v] += c;
    mc = max(mc,cost[v]);
  }

  void addEdge(int pr,int chi){
    child[pr].push_back(chi);
    par[chi] = pr;
  }

  int childsize(int u){
    return (int)child[u].size();
  }
};

int main(){

  int n,m;
  cin >> n >> m;
  Graph g(n);
  vector<int> tour(n,1);
  rep(i,n){
    int w;
    cin >> w;
    g.w[i] = w;;
  }
  rep(i,m){
    int u,v;
    cin >> u >> v;
    u--;v--;
    g.addEdge(u,v);
  }

  // 次数1の頂点を消していく
  queue<int> que;
  rep(i,n){
    if(g.degree(i)==1)que.push(i);
  }
  while(!que.empty()){
    int i = que.front();
    que.pop();
    if(i==0)continue;
    tour[i] = 0;
    rep(j,g.e[i].size()){
      int to = g.e[i][j];
      if(tour[to]){
        g.vdeg[to]--;
        if(g.vdeg[to]==1)que.push(to);
      }
    }
  }
  
  int cent = 0;
  int w = 0;
  rep(i,n)if(tour[i]==1){cent++;w+=g.w[i];}
  
  vector<int> inds(n);
  int index = 0;
  rep(i,n){
    if(tour[i]==0){
      inds[i] = index;
      index++;
    }
  }

  // gから巡回可能部分を縮約したグラフtを構築する
  int nt = n-cent+1;
  Graph t(nt);
  if (cent>0){
    t.w[nt-1] = w;
    //t.setWeight(nt-1,w);
  }
  index = 0;
  rep(i,n){
    if (tour[i]==0){
      t.w[inds[i]] = g.w[i];
      // t.setWeight(inds[i],g.w[i]);
      rep(j,g.e[i].size()){
        if(tour[g.e[i][j]]==0&&!t.isConnected(inds[i],inds[g.e[i][j]])){
          t.addEdge(inds[i],inds[g.e[i][j]]);
        } else if (tour[g.e[i][j]]==1) {
          t.addEdge(inds[i],nt-1);
        }
      }
    }
  }
  int rt;
  if (tour[0]==0){rt = inds[0];}
  else {rt = nt-1;}

  // BFS
  vector<bool> visited(nt,false);
  rep(i,nt)t.cost[i] = t.w[i];
  que.push(rt);
  int maxcost = 0;
  while(!que.empty()){
    int u = que.front();
    que.pop();
    visited[u] = true;
    if (t.cost[u]>maxcost)maxcost = t.cost[u];
    rep(i,t.e[u].size()){
      int to = t.e[u][i];
      if(!visited[to]){
        que.push(to);
        t.cost[to] += t.cost[u];
      }
    }
  }
  cout << maxcost << endl;

  return 0;
}