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 int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UnionFind {
  vector<int> data;
  UnionFind(){}
  UnionFind(int sz):data(sz, -1){}
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    if(data[x] < data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
};

#define MAX_N 100000

int N, M, num;
vint w, ord, low, cmp, conn, val, sz;
vector<vint> graph, tree;
vector< pair<int, int> > edges;
vector<bool> vis;

UnionFind uf;

void dfs(int u, int p, int &k) {
  vis[u] = true;
  ord[u] = low[u] = k++;
  for(int v : graph[u]) {
    if(!vis[v]) {
      dfs(v, u, k);
      chmin(low[u], low[v]);
      if(ord[u] >= low[v]) uf.unite(u, v);
    } else if(v != p) {
      chmin(low[u], ord[v]);
    }
  }
}

void compose() {
  uf = UnionFind(N);
  vis.resize(N);
  ord.resize(N);
  low.resize(N);
  cmp.resize(N);
  int k = 0;
  dfs(0, -1, k);
  num = 0;
  conn.resize(N);
  rep(u, N) if(u == uf.find(u)) conn[u] = num++;
  rep(u, N) cmp[u] = conn[uf.find(u)];
  tree.resize(num);
  for(auto e : edges) {
    int x = cmp[e.first], y = cmp[e.second];
    if(x == y) continue;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
}

int dp1[MAX_N]; // modoreru
int dp2[MAX_N]; // modoranai

int solve(int u, int p) {
  int res = 0;
  for(int v : tree[u]) {
    if(v == p) continue;
    chmax(res, solve(v, u));
    dp1[u] += dp1[v];
  }
  if(sz[u] >= 3 || dp1[u] > 0) dp1[u] += val[u];
  res += val[u];
  for(int v : tree[u]) {
    if(v == p) continue;
    chmax(res, dp1[u]-dp1[v]+dp2[v]);
  }
  return dp2[u] = res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  w.resize(N);
  rep(i, N) cin >> w[i];
  graph.resize(N);
  rep(i, M) {
    int u, v;
    cin >> u >> v; --u, --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
    edges.emplace_back(minmax(u, v));
  }
  compose();
  val.resize(num);
  sz.resize(num);
  rep(u, N) {
    val[cmp[u]] += w[u];
    sz[cmp[u]] = uf.size(u);
  }
  cout << solve(cmp[0], -1) << endl;

  return 0;
}