Maths Challenge IMO I saw this problem on a maths challenge book.

Given any set $A=\{a_1 ,a_2, a_3, a_4\}$ of four distinct positive integers, we denote the sum $a_1+a_2+a_3+a_4$ by $S_A$. Let $n_A$ denote the number of pairs $(i,j)$ with $1\leq i\leq j\leq 4$ for which $a_i +a_j$ divides $S_A$. Find all sets of four distinct positive integers which achieve the largest value of $n_A$.

I was thinking that $4\choose 2$ is $6$. So there should be six possible ways to pair all the elements of set $A$ that will divide $S_A$ provided that $a_i + a_i$ is not allowed. Well this is only my first thought, other ideas will be appreciated .
 A: WLOG $a_1<a_2<a_3<a_4$. For every permutation $a,b,c,d$ of $a_1,a_2,a_3,a_4$ we have $$a+b\mid (a+b+c+d)-(a+b)=c+d\implies \boxed{a+b\mid c+d}$$

Since $a_3+a_4>a_1+a_2$ and $a_2+a_4>a_1+a_3$ we can not have $a_3+a_4\mid a_1+a_2$ and $a_2+a_4\mid a_1+a_3$, so $n_A\leq 4$.
Since $a_1+a_4\mid a_2+a_3\;\;(*)$ only iff $$ka_4<k(a_1+a_4)\leq a_2+a_3 <2a_4$$
we get $k=1$, so $(*)$ is possible only if $\boxed{a_1+a_4= a_2+a_3}$
Now $$a_1+a_3\mid a_2+a_4 \implies a_1+a_3\mid (2a_2+a_3-a_1)-(a_1+a_3)=2(a_2-a_1)$$
So $$la_3<l(a_1+a_3) = 2(a_2-a_1) <2a_2 \implies l=1$$
so we have now $\boxed{ a_3=2a_2-3a_1}$ and $\boxed{ a_4=3a_2-4a_1}$.
Let $x=a_1$ and $y=a_2$. Finaly we have
$$a_1+a_2\mid a_3+a_4 \implies a_1+a_2\mid (5a_2-7a_1)$$ and $$a_1+a_2\mid 5(a_1+a_2)-(5a_2-7a_1) =12a_1 \implies 12x = m(x+y)$$  for some natural number $1\leq m<6$, since $x<y$. So $$\boxed{(12-m)x=my}$$

*

*For $m=1$ we get $y=11x$ and so $a_3=19x$ and $a_4= 29x$ and $x$ can be arbitrary positive integer.

*For $m=2$ we get $y=5x$ and so $a_3=7x$ and $a_4= 11x$ and $x$ can be arbitrary positive integer.

*For $m=3$ we get $y=3x$ and so $a_3=3x=a_2$ and so it is not OK.

*For $m=4$ we get $y=2x$ and so $a_3=x=a_1$ and so it is not OK.

*For $m=5$ we get $5y=7x$ and so $a_1=5t$, $a_2=7t$, $a_3=-t$ and so it is not OK.


So $$(a_1,a_2,a_3,a_4)\in \{(x,11x,19x,29x),(x,5x,7x,11x);\;x\in\mathbb{N}\}$$
