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

const int INF = 1e9;

void visit(vector< vector<int> > &G, int cur, int prev, vector< pair<int, int> > &brg, vector< vector<int> > &each_bcc, stack<int> &roots, stack<int> &S, vector<bool> &inS, vector<int> &order, int &k){
  order[cur] = ++k;
  S.push(cur);
  inS[cur] = true;
  roots.push(cur);
  for(int i = 0; i < G[cur].size(); ++i){
    int to = G[cur][i];
    if(!order[to]) visit(G, to, cur, brg, each_bcc, roots, S, inS, order, k);
    else if(to != prev && inS[to]){
      while(order[roots.top()] > order[to]) roots.pop();
    }
  }

  if(cur == roots.top()){
    if(prev != -1) brg.push_back(pair<int, int>(prev, cur));
    vector<int> bcc;
    while(1){
      int node = S.top();
      S.pop();
      inS[node] = false;
      bcc.push_back(node);
      if(node == cur) break;
    }
    each_bcc.push_back(bcc);
    roots.pop();
  }
}

void bridge(vector< vector<int> > &G, vector< pair<int, int> > &brg, vector< vector<int> > &each_bcc){
  int V = G.size();
  vector<int> order(V);
  vector<bool> inS(V);
  stack<int> roots, S;
  int k = 0;
  for(int i = 0; i < V; ++i){
    if(!order[i]) visit(G, i, -1, brg, each_bcc, roots, S, inS, order, k);
  }
}

void dfs(vector< vector<int> > &G, vector<int> &D, int s){
  for(int i = 0; i < G[s].size(); ++i){
    int v = G[s][i];
    if(D[v] > D[s] + 1){
      D[v] = D[s] + 1;
      dfs(G, D, v);
    }
  }
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> W(N);
  for(int i = 0; i < N; ++i) cin >> W[i];
  vector< vector<int> > G(N);
  for(int i = 0; i < M; ++i){
    int u, v;
    cin >> u >> v;
    --u;--v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  vector< vector<int> > each_bcc;
  vector< pair<int, int> > brg;
  bridge(G, brg, each_bcc);
  int V = each_bcc.size();
  vector<int> W_(V, 0), cmp(N);

  for(int i = 0; i < V; ++i){
    for(int j = 0; j < each_bcc[i].size(); ++j){
      cmp[each_bcc[i][j]] = i;
      W_[i] += W[each_bcc[i][j]];
    }
  }

  vector< vector<int> > G_(V);
  for(int i = 0; i < brg.size(); ++i){
    int u = brg[i].first, v = brg[i].second;
    G_[cmp[u]].push_back(cmp[v]);
    G_[cmp[v]].push_back(cmp[u]);
  }
  vector<int> D(V, INF);
  D[cmp[0]] = 0;
  dfs(G_, D, cmp[0]);
  int ans = 0;
  vector<int> R;
  for(int i = 0; i < V; ++i){
    if(G_[i].size() > 1 || i == cmp[0]) continue;
    int v = i;
    while(each_bcc[v].size() < 3 && v != cmp[0]){
      for(int j = 0; j < G_[v].size(); ++j){
        int u = G_[v][j];
        if(D[u] == D[v] - 1){
          v = u;
          break;
        }
      }
    }
    if(v != cmp[0]) R.push_back(v);
  }

  ans += W_[cmp[0]];
  vector<bool> visited(V, false);
  visited[cmp[0]] = true;
  for(int i = 0; i < R.size(); ++i){
    int v = R[i];
    while(!visited[v]){
      ans += W_[v];
      visited[v] = true;
      for(int j = 0; j < G_[v].size(); ++j){
        int u = G_[v][j];
        if(D[u] == D[v] - 1){
          v = u;
          break;
        }
      }
    }
  }
  int s = 0;
  for(int i = 0; i < V; ++i){
    if(G_[i].size() > 1 || visited[i]) continue;
    int v = i, t = 0;
    while(!visited[v]){
      t += W_[v];
      for(int j = 0; j < G_[v].size(); ++j){
        int u = G_[v][j];
        if(D[u] == D[v] - 1){
          v = u;
          break;
        }
      }
    }
    s = max(s, t);
  }
  ans += s;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 38728