I'm looking into the time complexities for various algorithms.

Taking the bubble sort algorithm specifically. It states that it has O(n2) worse-case time complexity. Wouldn't this mean that if we have 5 elements in an array to sort, this will take 5 + 5 + 5 + 5 + 5 times to sort it at a the worst case?

However, the algorithm is actually like this (n-1) + (n-2) + (n-3) ... etc.

Therefore with 5 elements in an array to sort, the time would be 5 + 4 + 3 + 2 + 1 , therefore 15 at worst case and not 25. Why is it still stated as O(n2) ? Thanks