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 <iostream>
#include <algorithm>
#include <vector>
#include <queue>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

void solvetree(int n) {
    std::vector<int> ws(n);
    for (auto& w : ws) std::cin >> w;

    Graph<> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;

        graph[u].emplace_back(u, v);
        graph[v].emplace_back(v, u);
    }

    std::vector<int> dist(n, -1);
    std::queue<int> que;

    dist[0] = ws[0];
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto e : graph[v]) {
            int u = e.dst;
            if (dist[u] != -1) continue;

            dist[u] = dist[v] + ws[u];
            que.push(u);
        }
    }

    std::cout << *std::max_element(dist.begin(), dist.end())
              << std::endl;
}

void solve() {
    int n, m;
    std::cin >> n >> m;

    if (m == n - 1) {
        solvetree(n);
        return;
    }

    std::vector<int> ws(n);
    for (auto& w : ws) std::cin >> w;

    Graph<> graph(n);
    std::vector<int> deg(n, 0);

    while (m--) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;

        ++deg[u], ++deg[v];
        graph[u].emplace_back(u, v);
        graph[v].emplace_back(v, u);
    }

    int ans = 0;

    std::queue<int> que;
    for (int v = 0; v < n; ++v) {
        if (deg[v] == 1) que.push(v);
    }

    std::vector<bool> onpath(n, false);
    onpath[0] = true;

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        if (onpath[v]) {
            ans += ws[v];
            ws[v] = 0;
        }

        for (auto e : graph[v]) {
            int u = e.dst;
            if (--deg[u] == 1) {
                que.push(u);
                if (onpath[v]) onpath[u] = true;
            }
        }
    }

    std::vector<int> dist(n, -1);
    for (int v = 0; v < n; ++v) {
        if (deg[v] > 1) {
            ans += ws[v];
            ws[v] = 0;
            que.push(v);
            dist[v] = 0;
        }
    }

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto e : graph[v]) {
            int u = e.dst;
            if (dist[u] != -1) continue;

            dist[u] = dist[v] + ws[u];
            que.push(u);
        }
    }

    ans += *std::max_element(dist.begin(), dist.end());
    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}