I agree it's slower because it goes over the array twice, how does that make it n^2 ?