def tkeInput():
    cakesNum, operationsNum = [int(i) for i in input('n, m: '.strip()).strip().split(' ')]

    # time for each cake
    times = [int(i) for i in input('times: ').strip().split(' ')]
    assert len(times) == cakesNum

    cakesTimes = {}
    for i in range(len(times)):
        cakesTimes['c' + str(i+1)] = times[i]

    operations = ()

    for i in range(operationsNum):
        operation = {}
        operation['op'],operation['from'], operation['to'], operation['time'] = [int(i) for i in input('operation: ').strip().split(' ')]
        operations += (operation,)

    return cakesTimes, operations

# execute
def op_1(rng, time, cakesTimes):
    rng = range(rng[0], rng[1] + 1)

    for cake in rng:
        cakeTime = cakesTimes['c' + str(cake)]
        if cakeTime > time:
            cakesTimes['c' + str(cake)] = cakeTime - time

    return cakesTimes

# print
def op_2(rng, time, cakesTimes):
    rng = range(rng[0], rng[1] + 1)
    counter = 0
    for cake in rng:
        cakeTime = cakesTimes['c' + str(cake)]
        if cakeTime == time:
            counter += 1

    print(counter)

def main():
    cakesTimes, operations = tkeInput()

    for operation in operations:
        op = operation['op']
        rng = (operation['from'], operation['to'])
        time = operation['time']
        if op == 1 :
            op_1(rng, time, cakesTimes)
        elif op == 2 :
            op_2(rng, time, cakesTimes)

main()