With gaps $p=w-x$, $q=x-y$, $r=y-z$, the differences are $p,q,r,p+q,q+r,p+q+r$. So $p+q+r=9$ and $\{p,q,r,p+q,q+r\}=\{2,3,4,5,7\}$; adding, $18+q=21$, so $q=3$ and $p+r=6$. Then $\{p,r,p+3,r+3\}=\{2,4,5,7\}$ forces $\{p,r\}=\{2,4\}$: gaps $(2,3,4)$ or $(4,3,2)$.
Gaps $(2,3,4)$: $w=z+9$, $x=z+7$, $y=z+4$, sum $4z+20=40$, $z=5$, giving $(14,12,9,5)$. Gaps $(4,3,2)$: $x=z+5$, $y=z+2$, sum $4z+16=40$, $z=6$, giving $(15,11,8,6)$.
The sum of the possible $w$ is $14+15=\boxed{29}$.