Prove that if $a_1,a_2,\cdots, a_n$ are real numbers then $$\sum_{i,j=1}^n f(a_i - a_j) = \int_{-\infty}^\infty \left(\sum_{i=1}^n \frac{1}{1+(x-a_i)^2}\right)^2 dx,$$ where $f(y) = \int_{-\infty}^\infty \frac{dx}{(1+x^2)(1+(x+y)^2)}$.
I know that $\int_{-\infty}^\infty \big(\sum_{i=1}^n \frac{1}{1+(x-a_i)^2}\big)^2 dx = \int_{-\infty}^\infty \sum_{i,j=1}^n\frac{1}{1+(x-a_i)^2}\frac{1}{1+(x-a_j)^2}dx$. Also, $\sum_{i,j=1}^n f(a_i-a_j) = \int_{-\infty}^\infty \sum_{i=1}^n \sum_{j=1}^n \frac{1}{(1+x^2)(1+(x+(a_i-a_j)^2)}dx.$ But I can't seem to show that for all $i,j$, $\frac{1}{(1+x^2)(1+(x+(a_i-a_j)^2)} =\frac{1}{1+(x-a_i)^2}\frac{1}{1+(x-a_j)^2}$. If this isn't true, then how do I show the given sums are equal?