#C8042. Maximum Height Difference

    ID: 51981 Type: Default 1000ms 256MiB

Maximum Height Difference

Maximum Height Difference

You are given N trees, each with a given height, and M bidirectional paths connecting some pairs of trees. Each path directly connects two trees. Your task is to compute the maximum absolute difference in height between any two trees that are directly connected by a path.

Mathematically, for each edge connecting tree i and tree j, the height difference is given by \(|h_i - h_j|\). You should output the maximum value among these differences.

Note: The input is given via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The input consists of several lines:

  1. The first line contains two integers N and M, where N is the number of trees and M is the number of paths.
  2. The second line contains N space-separated integers representing the heights of the trees.
  3. The next M lines each contain two integers u and v (1-indexed), indicating there is a direct path between tree u and tree v.

outputFormat

Output a single integer: the maximum absolute difference in height between any two trees directly connected by a path.

## sample
5 4
3 7 5 2 9
1 2
2 3
1 4
4 5
7