To optimize bubble sort, all we have to do is subtract how many values we've already sorted. That's i!

There! We've just created an optimized version of bubble sort!