#include <bits/stdc++.h>
using namespace std;
int arr[1000007];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, q, l, r, k;

    cin>>n>>q;
    for (int i = 0; i < n; i++)
        cin >> arr[i+1];
    for (int i = 0; i < q; i++){
        cin >> k >> l >> r;
        k = (r-l+1);
        if (l == r && arr[l] == -1) k = 2;
        if (arr[l]+arr[r] == -2) k-=2;
        if (arr[l]+arr[r] == 0) k--;
        cout << k << endl;
    }
}
