How do these 2 nested for loops differ in terms of Big Oh Loop 1:

sum $\gets 0$ 
  for $i\gets 1$ to $n$ do 
  $~~~~$ for $j \gets 1$ to $i^2$ do 
  $~~~~~~~~~$ sum $\gets$ sum + ary$[i]$

Loop 2:

sum $\gets 0$ 
  for $i\gets 1$ to $n^2$ do 
  $~~~~$ for $j \gets 1$ to $i$ do 
  $~~~~~~~~~$ sum $\gets$ sum + ary$[i]$

I know this summation formula is $\sum_{i=1}^{n}i^2=n\left(n+1\right)\left(2n+1\right)/6\sim n^{3}/3,$

The first one runs in
$$
\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6} = \Theta\left(n^3\right)
$$
and the second one takes
$$
\sum_{i=1}^{n^2} i = \frac{n^2\left(n^2+1\right)}{2} = \Theta\left(n^4\right)
$$
