Suppose that $(a_1,\ldots,a_{20})$ and $(b_1,\ldots,b_{20})$ are two sequences of integers such that the sequence $(a_1,\ldots,a_{20},b_1,\ldots,b_{20})$ contains each of the numbers $1,\ldots,40$ exactly once.  What is the maximum possible value of the sum \[\sum_{i=1}^{20}\sum_{j=1}^{20}\min(a_i,b_j)?\]

Let's think step by step and output the final answer within \boxed{}.
user