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]