#include <bits/stdc++.h>
#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))
constexpr bool dbg = 1;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl
#define int long long
#define ld long double
#define pb push_back
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n;
cin >> n;
vector<int> v(n);
repIn(i,v) cin >> i;
int q;
cin >> q;
while(q--) {
int x, y, a, b;
cin >> x >> y >> a >> b;
v[x - 1] = y;
int cs = v[a], wh = 0, op1 = b - a, op2 = b - a, xs = -1;
rep(i, a + 1, b) {
if(!wh) {
if(xs == -1) xs = v[i - 1], cs = v[i];
if(cs > xs) wh ^= 1, xs = -1;
else cs += v[i], op1--;
}
if(wh) {
if(cs > v[i]) cs = v[i], wh ^= 1;
else cs += v[i], op1--;
}
}
if(xs != -1 && cs <= xs) op1--;
cs = v[a], wh = 1, xs = -1;
rep(i, a + 1, b) {
if(!wh) {
if(xs == -1) xs = v[i - 1], cs = v[i];
if(cs > xs) wh ^= 1, xs = -1;
else cs += v[i], op2--;
}
if(wh) {
if(cs > v[i]) cs = v[i], wh ^= 1;
else cs += v[i], op2--;
}
}
if(xs != -1 && cs <= xs) op2--;
cout << max(op1, op2) << '\n';
}
}