Jaehong loves going up to the roof of his house. Last night's storm broke every ladder that led up there. He will use the two long logs he already owns as the side rails, buy wood only for the rungs, and build two ladders, the one he installs and a spare.
His design is this. He crosses the two logs of equal length at their midpoints so that the four endpoints form a rectangle of width W and height H. The two logs are then the diagonals of that rectangle. He cuts the rectangle into N equal parts with vertical lines, and on each line the segment joining the two points where the line meets the logs becomes one rung. If the two points are at the same position, that rung has length 0. The rungs at the two ends rest on the ground, so he does not buy them, and only the N−1 inner lines count. Compute the total length of wood Jaehong has to buy for the rungs.