#C8035. Taco Points of Interest

    ID: 51973 Type: Default 1000ms 256MiB

Taco Points of Interest

Taco Points of Interest

You are given a network of cities connected by bidirectional routes. Each city has a certain number of points of interest. A connected component of cities allows you to visit all its cities and sum their points of interest. Your task is to determine the maximum possible sum of points of interest over all connected components.

Input: The first line contains two integers \(N\) and \(M\), representing the number of cities and the number of connections, respectively. The second line contains \(N\) integers, where the \(i\)-th integer represents the points of interest in city \(i\). Then \(M\) lines follow, each containing two integers \(u\) and \(v\), indicating a bidirectional connection between city \(u\) and city \(v\>.

Output: Output a single integer denoting the maximum sum of points of interest that can be collected from any connected component of cities.

inputFormat

The first line contains two integers \(N\) and \(M\).

The second line contains \(N\) space-separated integers representing the points of interest of the cities.

Each of the following \(M\) lines contains two integers \(u\) and \(v\) indicating a bidirectional connection between cities \(u\) and \(v\).

outputFormat

Output a single integer: the maximum sum of points of interest among all connected components.

## sample
5 4
3 2 1 10 4
1 2
2 3
3 4
4 5
20