I'm learning about the analysis of algorithms and I'm encountering some steps in an explanation which I can't quite understand (log is a logarithm with base 2 in this context).

$\displaystyle c \log n + 1 + \sum_{i=0}^{n^2 - 1} (10 + 10 + \sum_{j=0}^{\frac{i}{\log n}} 20) \leq$

$\displaystyle c \log n + 1 + \sum_{i=0}^{n^2 - 1} ( \sum_{j=0}^{1 + \frac{i}{\log n}} 20) \leq$

$\displaystyle c \log n + 1 + \sum_{i=0}^{n^2 - 1} (20(2 + \frac{i}{\log n})) \leq$

The step from the second to third doesn't quite click, but it goes on:

$\displaystyle c \log n + 1 + 20 \sum_{i=0}^{n^2 - 1} (2 + \frac{i}{\log n}) \leq$

$\displaystyle c \log n + 1 + 20 \sum_{i=0}^{n^2 - 1} 2 + 20 \sum_{i=0}^{n^2 - 1} \frac{i}{\log n}\leq$

The above step is a bit hazy too...

$\displaystyle c \log n + 1 + 40n^2 + \frac{20}{\log n}\sum_{i=0}^{n^2 - 1} i\leq$

$\displaystyle c \log n + 1 + 40n^2 + \frac{20}{\log n}\frac{n^2(n^2 - 1)}{2}\leq$

$\displaystyle c \log n + 1 + 40n^2 + \frac{10n^4}{\log n}$

Which is a worst-case running time of $\displaystyle O(\frac{n^4}{\log n})$

Basically I'm lacking insight into alot of the simplifications/reductions/steps taken to come to $\displaystyle c \log n + 1 + 40n^2 + \frac{10n^4}{\log n}$ I would very much appreciate some clarification on steps taken so I can apply this when I need to analyze algorithms myself