A ← 整数列 # 从 1 开始 AC[0] ← 0 for i ← 1 to N-1: AC[i] ← AC[i-1] + A[i] Q ← [l, r] 形式的问题数列 for q in Q: l ← q.l r ← q.r sum ← AC[r] - AC[l-1]