Hyunsung wants to install wells in villages for African children who cannot drink as much water as they need.
Each village needs a different number of wells. Installing one well in village A counts as one well for village A and for every village connected to A directly by a road. You may install several wells in the same village.
For example, suppose village A is connected to B and to C, and villages A, B, and C need 5, 10, and 7 wells respectively. If you install 5 wells in village A, villages B and C also have 5 wells each counted toward their needs.
Hyunsung donates a lot, so he does not have much money. There are n villages, village i needs at least Wi wells (W1,W2,…,Wn), and there are m roads between villages. Find the minimum total number of wells to install so that every village's requirement is met.