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;

struct data {
  int p, bf;
  long long sum;
};

struct Unionfind {
  vector<int> par;
  vector<int> treerank;
  Unionfind(int n = 1) { stree(n + 1); }
  void stree(int n = 1) {
    par.assign(n, -1);
    treerank.assign(n, 0);
  }
  int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[y];
    par[y] -= size(x);
    par[x] = y;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

long long n, m, sum = 0;
vector<long long> w, edge[100005], memo;
vector<bool> used, passed;
Unionfind uf;
queue<data> qu;

long long solve();
bool dfs(int now, int bf);

int main() {
  cin >> n >> m;
  w.resize(n);
  for(int i = 0; i < n; ++i) cin >> w[i];
  for(int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    edge[--x].push_back(--y);
    edge[y].push_back(x);
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  uf = Unionfind(n);
  sum = w[0];
  passed.assign(n, 0);
  used.assign(n, 0);
  dfs(0, -1);
  memo.assign(n, 0);
  for(int i = 0; i < n; ++i)
    if(uf.issame(i, 0)) {
      bool ch = 0;
      for(int j = 0; j < edge[i].size(); ++j)
        if(!uf.issame(0, edge[i][j])) {
          ch = 1;
          break;
        }
      if(ch) qu.push({i, -1, 0});
    }
  while(!qu.empty()) {
    data now = qu.front();
    qu.pop();
    if(memo[now.p] != now.sum) continue;
    for(int i = 0; i < edge[now.p].size(); ++i)
      if(edge[now.p][i] != now.bf &&
         !uf.issame(0, edge[now.p][i])) {
        data nextp = now;
        nextp.p = edge[now.p][i];
        nextp.bf = now.p;
        nextp.sum += w[nextp.p];
        ans = max(ans, nextp.sum);
        if(memo[nextp.p] < nextp.sum) {
          memo[nextp.p] = nextp.sum;
          qu.push(nextp);
        }
      }
  }

  return ans + sum;
}

bool dfs(int now, int bf) {
  if(used[now]) return 1;
  if(passed[now]) return 0;
  used[now] = 1;
  passed[now] = 1;
  bool ans = 0;
  for(int i = 0; i < edge[now].size(); ++i)
    if(bf != edge[now][i]) ans |= dfs(edge[now][i], now);
  used[now] = 0;
  if(ans) {
    uf.uni(0, now);
    if(now != 0) sum += w[now];
  }
  return ans;
}