Here's the setup: you have an array of integers. You receive queries, each asking for the sum of elements from index to index .
For one query, you'd write a loop: start at , add elements until , return the sum. That's per query, which in the worst case is . Multiply by queries and you get . When both and are large, this is too slow. You need a smarter approach.