You can find the exact running time analysis with a google search or
just start to write your own analysis w.r.t for loops. But just note that
in all of them sum in total is calculated by telescopic sum, I mean may be
one of them is big but in each iteration for first loop takes O(n), and
totally takes O(n2).