#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define INF 1000000001LL
#define POT (1LL<<23)
#define INFL 1000000000000000099LL
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define pip pair<ll,pii>
#define ppp pair<pii,pii>
#define vi vector<ll>
#define vii vector<pii>
#define vvi vector<vi>
#define al(x) x.begin(),x.end()
#define rev(x) reverse(al(x))
#define X 18
#define FCTCST 7
template<typename T, typename U>
pair<T, U> operator+(const pair<T, U>& a, const pair<T, U>& b) {
return {a.first + b.first, a.second + b.second};
}
template<typename T, typename U>
pair<T, U> operator-(const pair<T, U>& a, const pair<T, U>& b) {
return {a.first - b.first, a.second - b.second};
}
template<typename T, typename U,typename Z>
pair<T, U> operator*(const pair<T, U>& a, const Z& b) {
return {a.first*b, a.second*b};
}
template<typename T, typename U,typename Z>
pair<T, U> operator/(const pair<T, U>& a, const Z& b) {
return {a.first/b, a.second/b};
}
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
os<<"{"<<p.ff<<", "<<p.ss<<"}";
return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
os << "{";
for (size_t i = 0; i < v.size(); ++i) {
if (i) os << ", ";
os << v[i];
}
os << "}";
return os;
}
template<ll MOD=998244353>
struct mint_t{
ll x;
mint_t(ll y=0){x=y%MOD;if(x<0)x+=MOD;}
mint_t& operator+=(const mint_t& a){if((x+=a.x)>=MOD)x-=MOD;return *this;}
mint_t& operator-=(const mint_t& a){if((x+=MOD-a.x)>=MOD)x-=MOD;return *this;}
mint_t operator+(const mint_t& a)const{mint_t res(*this);return res+=a;}
mint_t operator-(const mint_t& a)const{mint_t res(*this);return res-=a;}
mint_t& operator*=(const mint_t& a){(x*=a.x)%=MOD;return *this;}
mint_t operator*(const mint_t& a)const{mint_t res(*this);return res*=a;}
mint_t fp(ll y)const{
mint_t a=1,b=x;
while(y){
if(y&1)a*=b;
b*=b;
y/=2;
}
return a;
}
mint_t& operator/=(const mint_t& a){(*this)*=a.fp(MOD-2);return *this;}
mint_t operator/(const mint_t& a)const{mint_t res(*this);return res/=a;}
};
#define mint mint_t<>
template<long long MOD>
istream& operator>>(istream& in, mint_t<MOD>& a){
ll x;
in>>x;
a=mint_t<MOD>(x);
return in;
}
template<long long MOD>
istream& operator<<(istream& out, mint_t<MOD>& a){
out<<a.x;
return out;
}
mint fct[FCTCST];
mint bnm(ll a,ll b){
if(b>a || a<0)return 0;
return fct[a]/fct[b]/fct[a-b];
}
vi v;
ll n,a,b,c,d;
ll nx[250007];
ll bl=200;
pii nxj[250007];
ll c1=60;
void rec(ll x){
nx[x]=INFL;
ll aksm=0;
for(ll i=x+1;i<min(n,x+c1);i++){
if(aksm>v[i] && aksm>v[x]){nx[x]=i;break;}
aksm+=v[i];
}
for(ll i=x+1;i<min(n,x+c1);i++){
if(v[i]<v[x]){nx[x]=min(nx[x],nx[i]);break;}
}
}
void recl(ll x){
if(x>=0)
for(ll i=min(n-1,x*bl+bl-1);i>=x*bl;i--){
if(nx[i]/bl!=x)nxj[i]={nx[i],1};
else nxj[i]=nxj[nx[i]]+pii{0,1};
//cout<<i<<" "<<nxj[i]<<"\n";
}
}
pii gt(ll ak){
ll w1=0;
while(nx[ak]<=d){
if(nxj[ak].ff<=d){
w1+=2*nxj[ak].ss;
ak=nxj[ak].ff;
}
else {
w1+=2;ak=nx[ak];}
}
return {ak,w1};
}
void solve(){
cin>>n;
for(ll i=0;i<n;i++){
nxj[i]={INFL,0};
cin>>a;v.pb(a);
}
for(ll i=n-1;i+1;i--)rec(i);
for(ll i=n/bl;i+1;i--)recl(i);
//for(ll i=0;i<n;i++)cout<<nx[i]<<" "<<nxj[i]<<"\n";
ll q;
cin>>q;
for(ll i=0;i<q;i++){
cin>>a>>b>>c>>d;
a--;d--;
v[a]=b;
for(ll j=a;j>=max(a-c1,0LL);j--)rec(j);
recl(a/bl);
recl(a/bl-1);
ll ak=c;
ll w1=1;
pii pm=gt(ak);
ak=pm.ff;
w1+=pm.ss;
ll s=0;
for(ll j=d;j>=ak;j--){
if(s>v[j]){
w1++;break;
}
s+=v[j];
}
ll w2=0;
ll sm=0;
for(ll j=c;j<=d;j++){
if(sm>v[j]){
w2=2;
ak=j;
pii pm=gt(ak);
ak=pm.ff;
w2+=pm.ss;
ll s=0;
for(ll j=d;j>=ak;j--){
if(s>v[j]){
w2++;break;
}
s+=v[j];
}
break;
}
sm+=v[j];
}
cout<<max(w1,w2)<<"\n";
}
}
int main(){
fct[0]=1;
for(ll i=1;i<FCTCST;i++)fct[i]=fct[i-1]*i;
ll t=1;
//cin>>t;
for(ll i=1;i<=t;i++){
//cout<<"Case #"<<i<<": ";
solve();
}
}