Average Case Analysis for finding max in array with duplicated element
Let us consider the following distribution: each array element is chosen independently and uniformly from $\{1,\ldots,m\}$. Let us denote by $I_i$ the indicator variable for the event that ( ** ) gets executed for the $i$th element (so $I_i = 1$ if ( ** ) gets executed, and $I_i = 0$ otherwise). Linearity of expectation shows that the expected number of times that (**) gets executed is $$ \sum_{i=2}^n \Pr[I_i]. $$
(This uses the fact that $\mathbb{E}[I_i] = \Pr[I_i]$.)

It remains to compute the probability of $I_i$. If $A[i] = j$ then (**) happens iff $A[1],\ldots,A[i-1] \in \{1,\ldots,j-1\}$, which happens with probability $\bigl(\tfrac{j-1}{m}\bigr)^{i-1}$. Therefore
$$
\Pr[I_i] = \sum_{j=2}^m \frac{1}{m} \left(\frac{j-1}{m}\right)^{i-1}.
$$
In total, we get
$$
\sum_{i=2}^n \Pr[I_i] = \sum_{j=2}^m \frac{1}{m} \sum_{i=2}^n \left(\frac{j-1}{m}\right)^{i-1}.
$$
You take it from here.