{"raw_statement":[{"iden":"problem statement","content":"In Takahashi Kingdom, there are $N$ towns, called Town $1$ through Town $N$.  \nThere 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$.  \nGold 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).\nTakahashi, 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.  \nFind the maximum possible profit (that is, the selling price minus the buying price) in this plan."},{"iden":"constraints","content":"*   $2 \\le N \\le 2 \\times 10^5$\n*   $1 \\le M \\le 2 \\times 10^5$\n*   $1 \\le A_i \\le 10^9$\n*   $1 \\le X_i \\lt Y_i \\le N$\n*   $(X_i, Y_i) \\neq (X_j, Y_j) (i \\neq j)$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$A_1$ $A_2$ $A_3$ $\\dots$ $A_N$\n$X_1$ $Y_1$\n$X_2$ $Y_2$\n$X_3$ $Y_3$\n$\\hspace{15pt} \\vdots$\n$X_M$ $Y_M$"},{"iden":"sample input 1","content":"4 3\n2 3 1 5\n2 4\n1 2\n1 3"},{"iden":"sample output 1","content":"3\n\nWe can achieve the profit of $3$ yen, as follows:\n\n*   At Town $1$, buy one kilogram of gold for $2$ yen.\n*   Traverse Road $2$ to get to Town $2$.\n*   Traverse Road $1$ to get to Town $4$.\n*   At Town $4$, sell one kilogram of gold for $5$ yen."},{"iden":"sample input 2","content":"5 5\n13 8 3 15 18\n2 4\n1 2\n4 5\n2 3\n1 3"},{"iden":"sample output 2","content":"10\n\nWe can achieve the profit of $10$ yen, as follows:\n\n*   At Town $2$, buy one kilogram of gold for $8$ yen.\n*   Traverse Road $1$ to get to Town $4$.\n*   Traverse Road $3$ to get to Town $5$.\n*   At Town $5$, sell one kilogram of gold for $18$ yen."},{"iden":"sample input 3","content":"3 1\n1 100 1\n2 3"},{"iden":"sample output 3","content":"\\-99\n\nNote that we cannot sell gold at the town where we bought the gold, which means the answer may be negative."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}