During a recent campaign for office, a candidate made a tour of a country which we assume lies in a plane. On the first day of the tour he went east, on the second day he went north, on the third day west, on the fourth day south, on the fifth day east, etc. If the candidate went $n^{2}_{}/2$ miles on the $n^{\mbox{th}}_{}$ day of this tour, how many miles was he from his starting point at the end of the $40^{\mbox{th}}_{}$ day?
On the first day, the candidate moves $[4(0) + 1]^2/2\ \text{east},\, [4(0) + 2]^2/2\ \text{north},\, [4(0) + 3]^2/2\ \text{west},\, [4(0) + 4]^2/2\ \text{south}$, and so on. The E/W displacement is thus $1^2 - 3^2 + 5^2 \ldots +37^2 - 39^2 = \left|\sum_{i=0}^9 \frac{(4i+1)^2}{2} - \sum_{i=0}^9 \frac{(4i+3)^2}{2}\right|$. Applying [difference of squares](https://artofproblemsolving.com/wiki/index.php/Difference_of_squares), we see that 
\begin{align*} \left|\sum_{i=0}^9 \frac{(4i+1)^2 - (4i+3)^2}{2}\right| &= \left|\sum_{i=0}^9 \frac{(4i+1+4i+3)(4i+1-(4i+3))}{2}\right|\\ &= \left|\sum_{i=0}^9 -(8i+4) \right|. \end{align*}
The N/S displacement is 
\[\left|\sum_{i=0}^9 \frac{(4i+2)^2}{2} - \sum_{i=0}^9 \frac{(4i+4)^2}{2}\right| = \left|\sum_{i=0}^9 -(8i+6) \right|.\]
Since $\sum_{i=0}^{9} i = \frac{9(10)}{2} = 45$, the two distances evaluate to $8(45) + 10\cdot 4 = 400$ and $8(45) + 10\cdot 6 = 420$. By the [Pythagorean Theorem](https://artofproblemsolving.com/wiki/index.php/Pythagorean_Theorem), the answer is $\sqrt{400^2 + 420^2} = 29 \cdot 20 = \boxed{580}$.