import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._


  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val weights = readLine.trim.split(' ').map(_.toInt)
  val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}
  val dimensions = Array.tabulate(n){_ ⇒ 0}
  for (_ ← 0 until m){
    val Array(u, v) = readLine.trim.split(' ').map(_.toInt)
    edges(u - 1) ::= v - 1
    dimensions(u - 1) += 1
    edges(v - 1) ::= u - 1
    dimensions(v - 1) += 1
  }
  val singlePathMemo = Array.tabulate(n){_ ⇒ 0}
  dimensions.indices.tail.filter(i ⇒ dimensions(i) == 1).foreach(i ⇒ singlePathCost(i))
  println(singlePathMemo.max + dimensions.indices.filter(i ⇒ i == 0 || dimensions(i) != 1).map(i ⇒ weights(i)).sum)
  @tailrec
  def singlePathCost(current: Int, prev: Int = -1, result: Int = 0): Unit = {
      if (dimensions(current) != 1 || current == 0) {
        singlePathMemo(current) = math.max(singlePathMemo(current), result)
      }
      else {
        edges(current).filter(i ⇒ i == 0 || dimensions(i) != 1) match {
          case next::Nil ⇒
            dimensions(next) -= 1
            singlePathCost(next, current, math.max(singlePathMemo(current), result) + weights(current))
          case _ ⇒ ???
        }
      }
  }


  case class Cost(any: Int, one: Int)
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
    @inline
    def takeIf(@inline predicate: T ⇒ Boolean): Option[T] = Some(value).filter(predicate)
  }
}
