Problem Statement
In Takahashi Kingdom, there are $N$ towns, called Town $1$ through Town $N$.
There are also $M$ roads in the kingdom, called Road $1$ through Road $M$. By traversing Road $i$, you can travel from Town $X_i$ to Town $Y_i$, but not vice versa. Here, it is guaranteed that $X_i < Y_i$.
Gold is actively traded in this kingdom. At Town $i$, you can buy or sell $1$ kilogram of gold for $A_i$ yen (the currency of Japan).
Takahashi, a traveling salesman, plans to buy $1$ kilogram of gold at some town, traverse one or more roads, and sell $1$ kilogram of gold at another town.
Find the maximum possible profit (that is, the selling price minus the buying price) in this plan.
Constraints
$2 \le N \le 2 \times 10^5$$1 \le M \le 2 \times 10^5$$1 \le A_i \le 10^9$$1 \le X_i \lt Y_i \le N$$(X_i, Y_i) \neq (X_j, Y_j) (i \neq j)$- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
A_1 A_2 A_3 \dots A_N
X_1 Y_1
X_2 Y_2
X_3 Y_3
\hspace{15pt} \vdots
X_M Y_M
Output
Print the answer.
样例
4 3
2 3 1 5
2 4
1 2
1 3
3
5 5
13 8 3 15 18
2 4
1 2
4 5
2 3
1 3
10
3 1
1 100 1
2 3
-99
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。