When inserting into an AVL tree, the existing nodes are not compared with each other, so the probability of comparing $a_4$ and $a_9$ with each other when inserting $a_{40}$ is $0$.
On the other hand, the probability of comparing $a_{n}$ to both $a_4$ and $a_9$ is derivable asymptotically by considering how many comparisons one makes when doing an insert, which is $O(\lg n)$, making the total probability $O((\lg n/n)^2)$, which is very small - $o(1/n)$.
However, that's true only asymptotically. To get the result for $n = 40$, you have to analyze the expected number of comparisons when inserting into a tree of size $39$. That probably requires some heavier math.
To see how this can change, consider the probability of comparing $a_3$ to both $a_1$ and $a_2$ when inserting $a_3$, which I think is $2/3$.