n = gets.to_i
maxs = gets.chomp.split(" ").map(&:to_i)
q = gets.to_i
boxes = Array.new(n){0}

for i in 0..(q-1)
    input = gets.chomp.split(" ").map(&:to_i)
    t = input[0]
    x = input[1]
    d = input[2]
    if t == 1 then # 収穫
        boxes[x-1] += d
        if boxes[x-1] > maxs[x-1] then
            puts x
            break
        end
    else # 出荷
        boxes[x-1] -= d
        if boxes[x-1] < 0 then
            puts x
            break
        end
    end
    puts 0 if i == q - 1
end
