import sys

n, q = map(int, sys.stdin.readline().split())
array = list(map(int, sys.stdin.readline().split()))

def isB(nums):
    LEN = len(nums)
    suml = 0
    sumr = sum(nums)
    Llen = 0
    for i in range(LEN):
        suml += nums[i]
        sumr -= nums[i]

        if suml < 0:
            flag = False
            suml -= nums[i]
        else:
            Llen += 1
        
        if sumr < 0:
            return Llen + isB(nums[i+1:LEN])

    return Llen

for _ in range(q):
    temp = list(sys.stdin.readline().split())
    if temp[0] == '1':
        p = int(temp[1]) - 1
        array[p] *= -1
    else: # == '2'
        l = int(temp[1]) - 1
        r = int(temp[2])
        
        print(isB(array[l:r]))
