#include <iostream>
#include <vector>
using i64 = long long;

template <class T = long long int>
class Bit {
    private:
    unsigned len;
    T init;
    std::vector<T> arr;

    public:
    Bit(unsigned length, T initialValue = 0): len(length), init(initialValue), arr(len + 1, init) {}
    void update(unsigned a, T newval) {
        for (unsigned x = a; x <= len; x += x & -x) arr[x] += newval;
    }
    T query(unsigned a) const {
        T ret = init;
        for (unsigned x = a; x > 0; x -= x & -x) ret += arr[x];
        return ret;
    }
};

int main() {
    int n, q;
    std::cin >> n >> q;

    Bit<> b(n + 1);
    for (int i = 0; i < n; i++) {
        i64 a;
        std::cin >> a;
        b.update(i + 1, a);
    }

    while (q--) {
        int t, x, y;
        std::cin >> t >> x >> y;
        if (t) std::cout << b.query(y) - b.query(x) << '\n';
        else b.update(x + 1, y);
    }

    return 0;
}

#include<bits/stdc++.h>
#define maxn 100005
#define endl '\n'
using namespace std;
int arr[maxn],brr[maxn],pre[maxn];
struct sqrtd {
	int next,cnt;
}table[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	for(int i=1;i<n;i++)
		brr[i] = arr[i+1] - arr[i] , pre[i] = brr[i] + pre[i-1];
	n--;
	
	int L;
	cin >> L;
	
	int box = sqrt(n);
	for(int i=1;i<=n;i++) {
		int tem_cnt = 0 , bound = min((i/box+1)*box,n);
		int j , sum = 0;
		for(j=i;j<=bound;) {
			sum = 0;
			do {
				sum += brr[j++];
			} while(j <= bound && sum + brr[j] <= L);
			tem_cnt++;
		}
		if(j > bound && j <= n && sum + brr[j] <= L) {
			int l = j , r = n , m;
			while(true) {
				if(r-l<3) {
					for(m=l;m<=r && pre[m]-pre[j-1]+sum <= L;m++);
					break;
				}
				m = (l+r)>>1;
				if(pre[m]-pre[j-1]+sum <= L)
					l = m;
				else
					r = m-1;
			}
			j = m;
		}
		table[i] = {j,tem_cnt};
	}
	
	int q;
	cin >> q;
	while(q--) {
		int l,r;
		cin >> l >> r;
		if(l > r)	swap(l,r);
		r--;
		int ans = 0;
		while(l <= r && l/box != r/box) {
			ans += table[l].cnt;
			l = table[l].next;
		}
		if(l <= r && l/box == r/box) {
			while(l <= r) {
				int sum = 0;
				do {
					sum += brr[l++];
				} while(l <= r && sum + brr[l] <= L);
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
