The values of $f$, $g$, $h$ and $j$ are 5, 6, 7 and 8, but not necessarily in that order. What is the largest possible value of the sum of the four products $fg$, $gh$, $hj$ and $fj$?
Let's say $f,g$ are permuted. That means $f'=g$ and $g'=f$. Before the permutation, the sum was $(f)(g)+(g)(h)+(h)(j)+(f)(j)$. After the permutation, the sum is $(g)(f)+(f)(h)+(h)(j)+(g)(j)$. So the difference between the two is $(g)(f)+(f)(h)+(h)(j)+(g)(j) - [(f)(g)+(g)(h)+(h)(j)+(f)(j)]$. But that is just $(f)(h)+(h)(j)+(g)(j)+(g)(f)-(f)(g)-(g)(h)-(h)(j)-(f)(j)$. Which simplifies to $fh+hj+gj+gf-fg-gh-hj-fj$. So the difference between the two sums is $f(h-j)-g(h-j)$. Which equals $(f-g)(h-j)$. That's right. Since $h-j$ and $f-g$ have different signs, one of them must be $\leq 0$. So either $h-j\leq 0$ or $f-g\leq 0$. Yes, we can assume that $f$ is the smallest of the four. Then, $f-g\leq 0$. What is the sum for that arrangement? It is $5*6+6*8+8*7+5*7$. And that is $30+48+56+35$. So the sum is $169$. Right. So the answer is $169$.

