If we have two identical sets $A_1 = A_2 $, and we were asked to get the maximum sum of multiplying one distinct element from $A_1$ by another distinct element of $A_2$, for all elements in $A_1$.
For example, if $A_1 = A_2 = \{1, 0, 4, 5\}$, one (not maximum) option would be to do the following:
Multiply 1st element of $A_1$ by 2nd element of $A_2$, and vice versa (2nd of $A_1$ by 1st of $A_2$), then we can multiply 3rd of $A_1$ by 4th of $A_2$ and vice versa (4th of $A_1$ by 3rd of $A_2$):
$(1*0) + (0*1) + (4*5) + (5*4) = 40$
Clearly this will not give us the maximum value, and by only doing the correlation (dot product) we would get the maximum value, which is $(1*1) + (0*0) + (4*4) + (5*5) = 42$
My question is: is there a way to mathematically prove that? That by only doing the dot product we will get the max value?