{"problem":{"name":"Peddler","description":{"content":"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 To","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc188_e"},"statements":[{"statement_type":"Markdown","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.\n\n## Constraints\n\n*   $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.\n\n## Input\n\nInput 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$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc188_e","tags":[],"sample_group":[["4 3\n2 3 1 5\n2 4\n1 2\n1 3","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."],["5 5\n13 8 3 15 18\n2 4\n1 2\n4 5\n2 3\n1 3","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."],["3 1\n1 100 1\n2 3","\\-99\n\nNote that we cannot sell gold at the town where we bought the gold, which means the answer may be negative."]],"created_at":"2026-03-03 11:01:14"}}