Under construction

Still being built. Things may change

Escape

Time limit2sMemory limit512 MB

Summary
Starting at vertex 1 in a connected undirected graph, walk without immediately reusing the edge you just came from, collecting each vertex's value the first time you visit it, and maximize the total.
Level

Hard8 of 10

Topics
Graph, DFS, Greedy, Dynamic programming
Solved
No attempts yet

Problem

You are given an undirected graph whose vertices carry positive values. The vertices are numbered from 1 to NN, and the ii-th vertex has value wiw_i. You start at vertex 1 and may move around the graph under the constraint that you cannot traverse the edge you just came from. At each vertex, you gain points equal to that vertex's value, but only the first time you visit it.

Find the maximum total number of points you can obtain.

Input

The input is given from standard input in the following format.

NN MM

w1w_1 w2w_2 ...... wNw_N

u1u_1 v1v_1

u2u_2 v2v_2

......

uMu_M vMv_M

The first line contains the number of vertices NN and the number of edges MM of the graph. The second line contains the value wiw_i of each vertex. The following MM lines each contain the numbers of the two vertices connected by an edge.

Output

Output the answer on one line.

Constraints

  • 1≤N≤1000001 \leq N \leq 100000
  • N−1≤M≤100000N-1 \leq M \leq 100000
  • 1≤wi≤10001 \leq w_i \leq 1000
  • 1≤ui,vi≤N1 \leq u_i, v_i \leq N
  • There are no multiple edges or self-loops
  • The graph is connected

Examples2

  1. Example 1

    Input
    6 6
    1 2 3 4 5 6
    1 2
    2 3
    3 4
    1 4
    4 5
    5 6
    
    Expected output
    21
    
  2. Example 2

    Input
    7 8
    1 3 3 5 2 2 3
    1 2
    2 3
    3 1
    1 4
    1 7
    1 5
    1 6
    5 6
    
    Expected output
    16