Distinct Binary Heaps
If the duplicate element is the maximum element, the answer is the same as when all numbers are distinct. Let's say the duplicate element is $a_1, a_2$. Even though they are the same, we can treat it as $a_1 &gt; a_2$, and then remove the duplicate heaps where the only difference is the exchange of $a_1, a_2$, but that is not possible because $a_1$ is always at the root. So no duplicates found.

If the duplicate element is the minimum element, the problem gets more interesting. Let $S(n)$ be the number of max heaps such that the minimum element is duplicated, and $T(n)$ be the number of max heaps such that there are no duplicates. We already know that

$$T(n) = {{n-1}\choose {l}} \times T(l) \times T(r)$$

with base case $T(1) = 1$.

For the duplicate case, we have 3 cases. We can put them both into the left subtree, both into the right subtree, or one in each subtree. Hence, the recursion is

$$S(n) = {{n-3}\choose {l-2}} S(l) T(r) + {{n-3}\choose {r-2}} T(l) S(r) + {{n-3}\choose {l-1}} T(l) T(r)$$

with base case $S(1) = 0, S(2) = 1, S(3) = 1$.