The members of a club are connected to each other by secret lines. There are N members, and each member has a nerd power V and a position X on a one dimensional axis. Laying one line needs a special material that withstands the nerd power of both endpoints. The number of units of material for the line between member a and member b is the distance between them multiplied by the larger of their two nerd powers.
∣Xa−Xb∣×max(Va,Vb)
All of the members are on good terms, so every pair of two different members needs exactly one direct line. Compute the total number of units of material needed to lay all of the lines.