G. Gaming!
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output

Womais is playing a video game. Call a directed graph valid if it does not contain self-loops, and every vertex has at most one incoming and at most one outgoing edge. The game state consists of a valid directed graph with a weight attached to each vertex. Womais starts the game with some valid graph and a score of 0. His moves consist of adding edges to this graph. He can add any edge, provided that the resulting graph is still valid. When Womais adds an edge from a vertex with weight $$$a$$$ to a vertex with weight $$$b$$$, his score increases by $$$(a+b)^2$$$. What is the highest score Womais can achieve from a given game state? It is provable that the answer is always finite.

Input

The first line of the input contains two positive integers $$$n$$$ ($$$1 \leq n \leq {10}^5$$$) and $$$m$$$ ($$$0 \leq m \leq {10}^5$$$). The following line contains $$$n$$$ integers $$$w_i$$$ ($$$1 \leq w_i \leq 10^5$$$), where $$$w_i$$$ is the weight in the $$$i$$$-th vertex. The remaining $$$m$$$ lines describe the edges of the initial game state, with the $$$i$$$-th line consisting of two integers $$$a_i, b_i$$$ ($$$1 \leq a_i, b_i \leq n$$$) representing a directed edge from $$$a_i$$$ to $$$b_i$$$. It is guaranteed that the graph described in the input is valid.

Output

Output should be a single integer representing the maximum score Womais can achieve from the given game state.

Example
Input
3 1
3 3 10
2 3
Output
205