#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;
int solve(vector<int> v) {
int n = v.size();
vector<pair<int, int>> dpA(n), dpD(n);
vector<int> ps(n + 1);
rep(i, 0, n) ps[i + 1] = ps[i] + v[i];
rep(i, 1, n) {
dpA[i] = {0, i};
dpD[i] = {0, -i};
rep(j, 0, i) if(ps[i + 1] - ps[j + 1] > ps[j + 1] - ps[j + dpD[j].second]) dpA[i] = max(dpA[i], {dpD[j].first + 1, i - j - 1});
rep(j, 0, i) if(ps[i + 1] - ps[j + 1] < ps[j + 1] - ps[j - dpA[j].second]) dpD[i] = max(dpD[i], {dpA[j].first + 1, j - i + 1});
rep(j, 0, i) rep(k, j + 1, i) if(ps[i + 1] - ps[k + 1] < ps[k + 1] - ps[j + 1] && ps[k + 1] - ps[j + 1] > ps[j + 1] + ps[j - dpD[j].second]) dpD[i] = max(dpD[i], {dpD[j].first + 2, k - i + 1});
rep(k, 0, i) if(ps[i + 1] - ps[k + 1] < ps[k + 1]) dpD[i] = max(dpD[i], {1, k - i + 1});
}
return max(dpA.back().first, dpD.back().first) + 1;
}
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;
vector<int> v2;
rep(i, a, b) v2.pb(v[i]);
cout << solve(v2) << '\n';
}
}