Peanut is helping Rar the Cat catch some mice in Cat-town. Cat-town can be modelled as a series of N nodes and E edges where each node represents a Mouse-house containing some number of mice Mi, and each edge represents a one-way conveyor belt Peanut can travel on (he is very lazy, so he can't walk). When Peanut reaches a Mouse-house with a certain number of mice, he can catch all the mice in the Mouse-house, and the Mouse-house would become empty. Peanut begins at node 0. Help Peanut find out what is the maximum number of mice he can catch.
The first line of input will contain two integers, N and E.
The second line of input will contain N integers, with the ith integer representing the number of mice in the Mouse-house at node i.
The next E lines of input will contain two integers each, with each line representing the two nodes the edge connects.
The output should contain one line containing one integer, the maximum number of mice Peanut can catch.
7 10 6 3 5 7 8 2 2 0 1 2 0 1 4 1 3 2 6 2 4 2 5 5 4 6 1 3 6