I do not understand how complexity of n*sqrt(M) is accepted here

[Solution - Quiz Master (CF)](https://Solution Link on USACO)

I thought it should get TLE on an input where the vector a is 2,3,…1e5-1, 1e5.

I thought this because O(sqrt(1)+sqrt(2)+…sqrt(n)) is approximated to O(n^3/2).
I mean M can also go upto 1e5, so how is this accepted.

n^{3/2} isn’t large