2025 SSMO Accuracy Round Problems/Problem 8

Problem

We say that a permutation $(a_1, a_2, \dots ,a_{10})$ of the integers $1$ through $10$ inclusive is peaked if there do not exist three integers $1\le i < j < k \le 10$ such that $a_i > a_j$ and $a_j< a_k$. Let $\mathcal{S}$ be the set of all peaked permutations. If $a_p = 9$ and $a_q = 4$, the expected value of $|p-q|$ over all permutations in $\mathcal{S}$ can be written as $\frac{m}{n}$, where $m$ and $n$ are relatively prime positive integers. What is the value of $m+n$?

Solution