#K69977. Maximize DAG Node Value Sum

    ID: 33206 Type: Default 1000ms 256MiB

Maximize DAG Node Value Sum

Maximize DAG Node Value Sum

You are given a directed acyclic graph (DAG) with N nodes and M edges. Each node has an integer value. You are allowed to perform an operation on at most one node, which increases its value by 1.

Your task is to calculate the maximum possible sum of all node values after performing the operation at most once. Note that performing the operation is optional.

Note: The DAG structure is provided but does not affect the outcome since the operation only increases one node's value. Hence, the answer is simply the initial sum of node values plus 1.

The answer should be computed using the following formula in LaTeX format:

\( \text{Answer} = \sum_{i=1}^{N} a_i + 1 \)

inputFormat

The first line contains two space-separated integers N and M, representing the number of nodes and edges, respectively.

The second line contains N space-separated integers, where the i-th integer represents the value of the i-th node.

The next M lines each contain two space-separated integers u and v, indicating that there is an edge from node u to node v (nodes are 1-indexed).

outputFormat

Output a single integer, the maximum sum of all node values after performing the operation on at most one node.

## sample
4 4
3 2 5 1
1 2
2 3
3 4
1 3
12