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 MAX_V 114514
typedef pair<int,int> P;
vector<vector<int> > G,C,T;
//vector<int> G[MAX_V],C[MAX_V],T[MAX_V];
vector<int> ord,low,belong;
vector<P> B;
int V,K;
bool is_bridge(int u,int v){
  if(ord[u]>ord[v]) swap(u,v);
  return ord[u]<low[v];
}
typedef pair<int,P> PP;
void dfs(int uu,int pp,int d=0){
  //cout<<u<<" "<<p<<" "<<d<<endl;
  stack<PP> s;
  s.push(PP(0,P(uu,pp)));
  int u,p,i,v;
  u=uu;p=pp;
 BEGIN:
  ord[u]=low[u]=K;
  K++;
  for(i=0;i<(int)G[u].size();i++){
    v=G[u][i];
    if(v==p) continue;
    if(ord[v]>=0){
      low[u]=min(low[u],ord[v]);
    }else{
      s.push(PP(i,P(u,p)));
      p=u;
      u=v;
      goto BEGIN;
    RET:
      PP pp=s.top();s.pop();
      i=pp.first;u=pp.second.first;p=pp.second.first;
      v=G[u][i];
      low[u]=min(low[u],low[v]);
    }
    if(is_bridge(u,v)) B.push_back(P(u,v));
  }
  
  if(!s.empty()){
    goto RET;
  }
  
}
void fill_component(int c,int u){
  C[c].push_back(u);
  belong[u]=c;
  for(int v:G[u]){
    if(belong[v]>=0||is_bridge(u,v)) continue;
    fill_component(c,v);
  }
}
void add_component(int u){
  if(belong[u]>=0) return;
  C.emplace_back();
  fill_component(C.size()-1,u);
}

void biconnectedgraph(int n){
  K=0;
  ord.clear();
  ord.resize(n,-1);
  low.clear();
  low.resize(n);
  belong.clear();
  belong.resize(n,-1);
  //puts("OK2");
  for(int v=0;v<n;v++){
    if(ord[v]>=0) continue;
    //cout<<v<<endl;
    dfs(v,-1);
  }
  //puts("OK3");
  C.clear();
  for(int i=0;i<(int)B.size();i++){
    add_component(B[i].first);
    add_component(B[i].second);
  }
  add_component(0);
  V=C.size();
  T.clear();
  T.resize(V);
  for(int i=0;i<(int)B.size();i++){
    int u=belong[B[i].first],v=belong[B[i].second];
    T[u].push_back(v);
    T[v].push_back(u);
  }
}

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

static int wei[MAX_V],memo[MAX_V];
static bool used[MAX_V],dele[MAX_V];
bool flag=0;
int root,xyz;
void dfs2(int v,int p){
  used[v]=1;
  if(v!=root&&(int)C[v].size()>1){
    if(v==xyz) xyz=root;
    flag=1;
    dele[v]=1;
    for(int k:T[v])
      T[root].push_back(k);
    wei[root]+=wei[v];
    return;
  }
  for(int i=0;i<(int)T[v].size();i++){
    int u=T[v][i];
    if(u==p) continue;
    if(used[u]) continue;
    dfs2(u,v);
    if(flag){
      if(~p){
	if(v==xyz) xyz=root;
	dele[v]=1;
	for(int k:T[v])
	  T[root].push_back(k);
	wei[root]+=wei[v];
	return;
      }else{
	flag=0;
      }
    }
  }
}

int dfs3(int v,int p){
  int res=wei[v];
  for(int u:T[v]){
    if(dele[u]||u==p) continue;
    res=max(res,wei[v]+dfs3(u,v));
  }
  //if(p==xyz) cout<<v<<" "<<res<<endl;
  return res;
}
priority_queue<int> tmp;
int ans=0;
bool flag2=0;
int dfs4(int v,int p){
  //cout<<v<<" "<<p<<endl;
  if(~memo[v]) return memo[v];
  if(v==root){
    flag2=1;
    ans+=wei[v];
    for(int u:T[v]) if(u!=p) tmp.push(dfs3(u,v));
    return 0;
  }
  int res=wei[v];
  for(int u:T[v]){
    if(dele[u]||u==p) continue;
    res=max(res,wei[v]+dfs4(u,v));
    if(flag2){
      ans+=wei[v];
      for(int k:T[v])
	if(u!=k&&k!=p) tmp.push(dfs3(k,v));
      break;
    }
  }
  return memo[v]=res;
}
signed main(){
  int n,m;
  cin>>n>>m;
  G.clear();
  G.resize(n);
  int w[n];
  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--;
    add_edge(u,v);
  }
  //puts("OK1");
  biconnectedgraph(n);
  //puts("OK");
  root=-1;
  for(int i=0;i<V;i++){
    for(int j=0;j<(int)C[i].size();j++){
      wei[i]+=w[C[i][j]];
      //w[C[i][j]]=0;
      if(j>0) root=i;
      if(C[i][j]==0) xyz=i;
    }
    //if(C[i].size()>1) cout<<i<<" "<<C[i].size()<<":"<<wei[i]<<endl; 
    //cout<<i<<":"<<wei[i]<<endl;
  }
  //for(int i=0;i<n;i++) assert(!w[i]);
  //cout<<C[xyz].size()<<":";for(int i:C[xyz]) cout<<" "<<i;cout<<endl;
  //cout<<wei[xyz]<<endl;
  if(~root){
    dfs2(root,-1);
    for(int i=0;i<V;i++) assert(used[i]);
  }
  //cout<<root<<"-"<<xyz<<endl;
  if(root<0||root==xyz) cout<<dfs3(xyz,-1)<<endl;
  else{
    memset(memo,-1,sizeof(memo));
    dfs4(xyz,-1);
    if(!tmp.empty()) ans+=tmp.top();
    cout<<ans<<endl;
  }
  return 0;
}