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>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
struct BiconectedGraph{
  int n;
  vector<vector<int> > G,C,T;
  vector<int> ord,low,belong;
  vector<P> B;
  BiconectedGraph(){}
  BiconectedGraph(int sz):n(sz),G(sz),C(sz),T(sz){}
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  void input(int m,int offset=0){
    int a,b;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      add_edge(a+offset,b+offset);
    }
  }
  
  bool is_bridge(int u,int v){
    if(ord[u]>ord[v]) swap(u,v);
    return ord[u]<low[v];
  }
  
  void dfs(int v,int p,int &k){
    ord[v]=low[v]=k;
    ++k;
    for(int u:G[v]){
      if(u==p) continue;
      if(ord[u]>=0){
  low[v]=min(low[v],ord[u]);
      }else{
  dfs(u,v,k);
  low[v]=min(low[v],low[u]);
      }
      if(is_bridge(u,v)) B.push_back(P(u,v));
    }
  }
  
  void fill_component(int c,int v){
    C[c].push_back(v);
    belong[v]=c;
    for(int u:G[v]){
      if(belong[u]>=0||is_bridge(u,v)) continue;
      fill_component(c,u);
    }
  }
  
  void add_component(int v,int &k){
    if(belong[v]>=0) return;
    fill_component(k++,v);
  }
  
  int build(){
    int k=0;
    ord.resize(n);
    low.resize(n);
    belong.resize(n);
    fill(ord.begin(),ord.end(),-1);
    fill(belong.begin(),belong.end(),-1);
    for(int v=0;v<n;v++){
      if(ord[v]>=0) continue;
      dfs(v,-1,k);
    }
    k=0;
    for(int i=0;i<(int)B.size();i++){
      add_component(B[i].first,k);
      add_component(B[i].second,k);
    }
    for(int v=0;v<n;v++) add_component(v,k);
    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);
    }
    return k;
  }
};
//END CUT HERE

int ans=0;

void dfs(int x,vector<int>&used,vector<vector<int> >&v,map<int,int>&m,int A){
  used[x]=1;
  int res=0;
  int f=0;
  int now=m[x];
  r(i,v[x].size()){
    if(used[v[x][i]])continue;
    dfs(v[x][i],used,v,m,A+now);
    f++;
  }
  if(f==0){
    ans=max(A+now,ans);
  }
  return ;
}

int n,m,w[100009],x[100009],y[1000009];

signed main(){
  cin>>n>>m;
  r(i,n)cin>>w[i];
  BiconectedGraph bcc(n);
  set<P>tt;
  r(i,m){
    cin>>x[i]>>y[i];
    x[i]--;y[i]--;
    if(x[i]==y[i])return 0;
    bcc.add_edge(x[i],y[i]);
    if(tt.count(P(x[i],y[i]))||tt.count(P(y[i],x[i])))exit(1);
    tt.insert(P(x[i],y[i]));
  }
  bcc.build();
  int cnt=0;
  map<int,int>M,count,wei;
  set<int>st;
  r(i,n){
    if(!st.count(bcc.belong[i])){
      st.insert(bcc.belong[i]);
      count[cnt]++;
      wei[cnt]+=w[i];
      M[bcc.belong[i]]=cnt++;
    }
    else{
      wei[M[bcc.belong[i]]]+=w[i];
      count[M[bcc.belong[i]]]++;
    }
  }
  
  BiconectedGraph B(cnt+1);
  int root = M[bcc.belong[0]];
  vector<P>hen;
  r(i,m){
    if(bcc.belong[x[i]]==bcc.belong[y[i]])continue;
    B.add_edge(M[bcc.belong[x[i]]],M[bcc.belong[y[i]]]);
    hen.push_back(P(M[bcc.belong[x[i]]],M[bcc.belong[y[i]]]));

  }
  r(i,cnt){
    if(count[i]>1)if(i!=root){
      B.add_edge(cnt,i);
      hen.push_back(P(cnt,i));
    }
  }
  B.add_edge(root,cnt);
  hen.push_back(P(root,cnt));
  B.build();
  st.clear();
  map<int,int>wei2;
  M.clear();
  int cnt2=0;
  r(i,cnt+1){
    if(!st.count(B.belong[i])){
      st.insert(B.belong[i]);
      wei2[cnt2]+=wei[i];
      M[B.belong[i]]=cnt2++;
    }
    else{
      wei2[M[B.belong[i]]]+=wei[i];
    }
  }
  int ii=0;
  vector<vector<int> >v(cnt2);
  r(i,hen.size()){
    int x=hen[i].first;
    int y=hen[i].second;
    if(B.belong[x]==B.belong[y])continue;
    x=M[B.belong[x]];
    y=M[B.belong[y]];
    v[x].push_back(y);
    v[y].push_back(x);
    ii++;
  }
  root = M[B.belong[root]];
  vector<int>used(cnt2,0);
  dfs(root,used,v,wei2,0);
  cout<<root+ans<<endl;
}