#include <iostream>
#include <vector>
using namespace std;

struct Graph {
    Graph(const int n)
    {
        edge.resize(n);
    }
    void addEdge(const int from, const int to)
    {
        edge[from].push_back(to);
        edge[to].push_back(from);
    }
    vector<vector<int>> edge;
};

int dfs(const Graph& g, const int s, vector<bool>& used, vector<bool>& compressed)
{
    used[s] = true;
    int removed = 0;
    int child = 0;
    for (const int to : g.edge[s]) {
        child++;
        if (used[to]) {
            continue;
        }
        removed += dfs(g, to, used, compressed);
    }
    if (s != 0 and removed + 1 == child) {
        compressed[s] = false;
        return 1;
    }
    return 0;
}

int weight_dfs(const Graph& g, const int s, const vector<int>& w, vector<bool>& visited)
{
    visited[s] = true;
    int weight = w[s];
    int maxi = 0;
    for (const int to : g.edge[s]) {
        if (visited[to]) {
            continue;
        }
        maxi = max(maxi, weight_dfs(g, to, w, visited));
    }
    return weight + maxi;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> w(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i];
    }
    Graph g(N);
    vector<int> u(M);
    vector<int> v(M);
    for (int i = 0; i < M; i++) {
        int u_, v_;
        cin >> u_ >> v_;
        u_--;
        v_--;
        u[i] = u_;
        v[i] = v_;
        g.addEdge(u_, v_);
    }

    vector<bool> used(N, false);
    vector<bool> compressed(N, true);

    dfs(g, 0, used, compressed);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (compressed[i]) {
            sum += w[i];
        }
    }
    w[0] = sum;
    Graph dec_g(N);
    for (int i = 0; i < M; i++) {
        int u_ = u[i];
        int v_ = v[i];
        if (compressed[u_]) {
            u_ = 0;
        }
        if (compressed[v_]) {
            v_ = 0;
        }
        if (u_ == 0 and v_ == 0) {
            continue;
        }
        dec_g.addEdge(u_, v_);
    }
    vector<bool> visited(N, false);
    cout << weight_dfs(dec_g, 0, w, visited) << endl;

    return 0;
}