Problem: You are a famous adventurer and have already won two dungeons. You got a new dungeon map with some walkways and a treasure trove. The map shows the value of the treasure in each treasure chest.

You can enter the dungeon from any treasure chest and escape the dungeon from any treasure chest. From invasion to escape, you can navigate through the passages between the treasure chests several times to get the treasures of the treasure chest you visited. According to the map, each passage can be bidirectional, and any treasure trove can be reached from any treasure trove via one or more passages. However, once the passage is passed, it can only be passed in the same direction as the first time after the second time. Treasure in the treasure chest can only be obtained the first time you visit it. At this time, I want to maximize the total value of the treasures I get.

Create a program that finds the maximum sum of the treasure values ​​that can be obtained between invasion and escape when given map information. However, it is assumed that the treasure house is assigned a number from 1 to N.



input

The input is given in the following format.


$ N $ $ M $
$ v_1 $
$ v_2 $
::
$ v_N $
$ s_1 $ $ t_1 $
$ s_2 $ $ t_2 $
::
$ s_M $ $ t_M $


The first line gives the number of treasure trove $ N $ ($ 2 \ leq N \ leq 10 ^ 5 $) and the number of passages $ M $ ($ 1 \ leq M \ leq 2 \ times 10 ^ 5 $). The following $ N $ line is given the value of the treasure in the $ i $ th treasure trove $ v_i $ ($ 1 \ leq v_i \ leq 1000 $). The following $ M $ line is given the treasure trove numbers $ s_i $, $ t_i $ ($ 1 \ leq s_i, t_i \ leq N, s_i \ net_i $) connected to both ends of each aisle. However, the passage connecting the same treasure chests cannot be given more than once.

output

The maximum value of the total value of the treasure that can be obtained is output in one line.

Examples

Input

5 4
2
1
3
6
4
1 2
2 3
2 4
4 5


Output

14


Input

None


Output

None

Solution (in CPP):

Solution:
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0415"

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#include <iostream>

#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
// work with multigraph
struct TwoEdgeConnectedComponents{
  vector<int> ord,low,par,blg,sz;
  vector<vector<int>> G,C;

  TwoEdgeConnectedComponents(int n):
    ord(n,-1),low(n),par(n,-1),blg(n,-1),sz(n,1),G(n){}

  void add_edge(int u,int v){
    if(u==v) return;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  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 &pos){
    ord[v]=low[v]=pos++;
    int dup=0;
    for(int u:G[v]){
      if(u==par[v] and !dup){
        dup=1;
        continue;
      }
      if(~ord[u]){
        low[v]=min(low[v],ord[u]);
        continue;
      }
      par[u]=v;
      dfs(u,pos);
      sz[v]+=sz[u];
      low[v]=min(low[v],low[u]);
    }
  }

  void fill_component(int v){
    C[blg[v]].emplace_back(v);
    for(int u:G[v]){
      if(~blg[u]||is_bridge(u,v)) continue;
      blg[u]=blg[v];
      fill_component(u);
    }
  }

  void add_component(int v,int &k){
    if(~blg[v]) return;
    blg[v]=k++;
    C.emplace_back();
    fill_component(v);
  }

  int build(){
    int n=G.size(),pos=0;
    for(int i=0;i<n;i++)
      if(ord[i]<0) dfs(i,pos);

    int k=0;
    for(int i=0;i<n;i++) add_component(i,k);

    return k;
  }

  const vector<int>& operator[](int i)const{return C[i];}

  vector<vector<int>> forest(){
    int n=G.size(),k=C.size();
    vector<vector<int>> T(k);
    for(int v=0;v<n;v++)
      for(int u:G[v])
        if(blg[v]!=blg[u])
          T[blg[v]].emplace_back(blg[u]);
    return T;
  }
};
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T>
struct DiameterForVertex{
  vector<T> vs,dp;
  vector<vector<int> > G;
  DiameterForVertex(int n):dp(n),G(n){}
  DiameterForVertex(vector<T> vs):vs(vs),dp(vs.size()),G(vs.size()){}

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

  void dfs(int v,int p,int &s){
    if(p<0) dp[v]=T(0);
    dp[v]+=vs[v];
    if(dp[s]<dp[v]) s=v;
    for(int u:G[v]){
      if(u==p) continue;
      dp[u]=dp[v];
      dfs(u,v,s);
    }
  }

  T build(){
    assert(!vs.empty());
    int s=0;
    dfs(s,-1,s);
    dfs(s,-1,s);
    return dp[s];
  }

  T build(vector<T> us){
    assert(us.size()==dp.size());
    vs=us;
    return build();
  }
};
//END CUT HERE
#ifndef call_from_test

// test build with argument vector<T>
signed ARC097_F(){
  int n;
  cin>>n;
  DiameterForVertex<int> G(n);
  vector<int> deg(n,0);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y);
    deg[x]++;
    deg[y]++;
  }

  string s;
  cin>>s;

  int cnt=(n-1)*2,num=0;
  queue<int> que;
  vector<int> dead(n,0);
  for(int i=0;i<n;i++){
    num+=(s[i]=='W');
    if((deg[i]==1)&&(s[i]=='B')){
      dead[i]=1;
      que.emplace(i);
    }
  }

  while(!que.empty()){
    int v=que.front();que.pop();
    cnt-=2;
    for(int u:G.G[v]){
      if(dead[u]) continue;
      deg[u]--;
      if(deg[u]==1&&(s[u]=='B')){
        dead[u]=1;
        que.emplace(u);
      }
    }
  }

  if(num<=1){
    cout<<num<<endl;
    return 0;
  }

  vector<int> vs(n,0);
  for(int i=0;i<n;i++){
    if(dead[i]) continue;
    vs[i]=deg[i]+(s[i]=='W');
    vs[i]%=2;
    cnt+=vs[i];
  }

  cout<<cnt-G.build(vs)*2<<endl;
  return 0;
}
/*
  verified on 2019/12/27
  https://atcoder.jp/contests/arc097/tasks/arc097_d
*/

signed main(){
  //ARC097_F();
  return 0;
}
#endif

#undef call_from_test

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  using ll = long long;

  int n,m;
  cin>>n>>m;
  vector<ll> vs(n);
  for(int i=0;i<n;i++) cin>>vs[i];

  TwoEdgeConnectedComponents C(n);
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    s--;t--;
    C.add_edge(s,t);
  }

  int k=C.build();
  vector<ll> sm(k,0);
  for(int i=0;i<n;i++)
    sm[C.blg[i]]+=vs[i];

  auto T=C.forest();

  ll ans=0;
  vector<int> used(k,-1);
  for(int i=0;i<k;i++){
    if(~used[i]) continue;
    int sz=0;
    queue<int> que;
    used[i]=sz++;
    que.emplace(i);

    vector<int> vv;
    vector<ll> ws;
    while(!que.empty()){
      int v=que.front();que.pop();
      vv.emplace_back(v);
      ws.emplace_back(sm[v]);
      for(int u:T[v]){
        if(~used[u]) continue;
        used[u]=sz++;
        que.emplace(u);
      }
    }

    DiameterForVertex<ll> H(ws);
    for(int v:vv)
      for(int u:T[v])
        if(u<v) H.add_edge(used[u],used[v]);

    chmax(ans,H.build());
  }

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