#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

struct Info{
	Info(){
		node_id = pre_node = sum_value = 0;
	}

	Info(int arg_node_id,int arg_pre_node,int arg_sum_value){
		node_id = arg_node_id;
		pre_node = arg_pre_node;
		sum_value = arg_sum_value;
	}
	bool operator<(const struct Info &arg) const{
		return sum_value < arg.sum_value;
	}

	int node_id,pre_node,sum_value;
};

int N,M;
int root;
int value[NUM],in_num[NUM],max_value[NUM];
bool is_cicle[NUM];
vector<int> G[NUM];



int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++)scanf("%d",&value[i]);

	for(int i = 0; i < N; i++)in_num[i] = 0;

	root = 0;
	int from,to;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		G[from].push_back(to);
		G[to].push_back(from);
		in_num[from]++;
		in_num[to]++;
	}

	for(int i = 0; i < N; i++)is_cicle[i] = true;

	queue<int> CALC;
	for(int i = 1; i < N; i++){
		if(in_num[i] == 1){
			is_cicle[i] = false;
			CALC.push(i);
		}
	}

	int node_id;
	int next_node,next_value;

	while(!CALC.empty()){
		node_id = CALC.front();
		CALC.pop();

		for(int i = 0; i < G[node_id].size(); i++){
			next_node = G[node_id][i];
			if(is_cicle[next_node] == false || next_node == root)continue;

			in_num[next_node]--;
			if(in_num[next_node] == 1){
				is_cicle[next_node] = false;
				CALC.push(next_node);
			}
		}
	}

	int ans = value[root];
	for(int i = 1; i < N; i++){
		if(is_cicle[i]){
			ans += value[i];
		}
	}

	int maximum = 0;
	for(int i = 0; i < N; i++)max_value[i] = 0;

	priority_queue<Info> Q;
	for(int i = 0; i < N; i++){
		if(!is_cicle[i])continue;

		for(int k = 0; k < G[i].size(); k++){
			next_node = G[i][k];
			if(is_cicle[next_node])continue;

			next_value = value[next_node];
			if(max_value[next_node] < next_value){
				max_value[next_node] = next_value;
				Q.push(Info(next_node,i,next_value));
			}
		}
	}

	Info info;
	while(!Q.empty()){

		info = Q.top();
		Q.pop();

		maximum = max(maximum,info.sum_value);

		if(info.sum_value < max_value[info.node_id]){
			continue;
		}else{
			for(int i = 0; i < G[info.node_id].size(); i++){
				next_node = G[info.node_id][i];
				if(next_node == info.pre_node || is_cicle[next_node] == true)continue;
				next_value = info.sum_value+value[next_node];

				if(max_value[next_node] < next_value){
					max_value[next_node] = next_value;
					Q.push(Info(next_node,info.node_id,next_value));
				}
			}
		}
	}

	printf("%d\n",ans+maximum);

	return 0;
}

