#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=0,mins=0;cin>>n>>w;long long int a[n+1];a[0]=0;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    long long int ans=w-(maxs-mins-1);
    if(ans<0)cout<<0;
    else cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN,mins=INT_MAX;long long int a[n+1];cin>>n>>w;a[0]=0;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    if(w<maxs || -1*mins>w){cout<<0;return 0;}
    long long int ans=w-maxs+mins+1;
    if(ans<0 || ans>w)cout<<0;
    else cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN,mins=INT_MAX;cin>>n>>w;long long int a[n+1];a[0]=0;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    long long int ans=w-(maxs-mins-1);
    if(ans<0 || ans>w)cout<<0;
    else cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN,mins=INT_MAX;long long int a[n+1];cin>>n>>w;a[0]=0;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    if(w<maxs || -1*mins>w){cout<<0;return 0;}
    long long int ans=(w-maxs<0)?-1:w-maxs;
    if(mins<0)
        ans+=mins;
    ans++;
    if(ans<0 || ans>w)cout<<0;
    else cout<<ans+1;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN;long long int a[n+1];cin>>n>>w;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];}
    long long int ans=(w-maxs<0)?-1:w-maxs;
    cout<<ans+1;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=0,mins=0;cin>>n>>w;long long int a[n+1];a[0]=0;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    long long int ans=w-(maxs-mins-1);
    if(ans<0 || ans>w)cout<<0;
    else cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN,mins=INT_MAX;long long int a[n+1];cin>>n>>w;a[0]=0;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    if(w<maxs || -1*mins>w){cout<<0;return 0;}
    long long int ans=(w-maxs<0)?-1:w-maxs;
    if(mins<0)
        ans+=mins;
    ans++;
    if(ans<0 || ans>w)cout<<0;
    else cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN;long long int a[n+1];cin>>n>>w;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];}
    long long int ans=max(-1,w-maxs);
    cout<<ans+1;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN,mins=INT_MAX;long long int a[n+1];cin>>n>>w;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    long long int ans=(w-maxs<0)?-1:w-maxs;
    if(mins<0)
        ans-=mins;
    cout<<ans+1;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
    long long int n,w,maxs=INT_MIN,mins=INT_MAX;long long int a[n+1];cin>>n>>w;
    for(long long int i=1;i<=n;i++){cin>>a[i];a[i]+=a[i-1];if(a[i]>maxs)maxs=a[i];if(a[i]<mins)mins=a[i];}
    long long int ans=(w-maxs<0)?-1:w-maxs;
    if(mins<0)
        ans+=mins;
    cout<<ans+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid)==0)
			lo=mid;
		else
			hi=mid-1;
	}
	lo++;
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid)==1)
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>m)
		{
			cout << "0" << endl;
			return 0;
		}
	}
	int hi= binsearch2(-10,1e10);
	int lo= binsearch(-10,1e10);
	int xx= check1(lo);
	int yy= check2(hi);
	if( hi-lo+1 <0)
	{
		cout << "0" << endl;
	}
	else
	{
		cout <<  hi-lo+1  << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid)==0)
			lo=mid;
		else
			hi=mid-1;
	}
	lo++;
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid)==1)
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	int hi= binsearch2(0,1e10);
	int lo= binsearch(-1,1e10);
	cout << hi-lo+1 << endl;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid))
			hi=mid;
		else
			lo= mid+1;
	}
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid))
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>m)
		{
			cout << "0" << endl;
			return 0;
		}
	}
	int hi= binsearch2(0,m);
	int lo= binsearch(0,m);
	//cout << check1(hi) << " " << check1(lo) << " " << check2(hi) << " " << check2(lo) << endl;
	if(check1(hi)==0 || check1(lo)==0 || check2(hi)==0 ||check2(lo)==0 )
	{
		cout << "0" << endl;
		return 0;
	}
		cout << hi-lo+1 << endl;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid)==0)
			lo=mid;
		else
			hi=mid-1;
	}
	lo++;
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid)==1)
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>m)
		{
			cout << "0" << endl;
			return 0;
		}
	}
	int hi= binsearch2(0,1e10);
	int lo= binsearch(-1,1e10);
	cout << hi-lo+1 << endl;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid)==0)
			lo=mid;
		else
			hi=mid-1;
	}
	lo++;
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid)==1)
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>m)
		{
			cout << "0" << endl;
			return 0;
		}
	}
	int hi= binsearch2(-1,1e10);
	int lo= binsearch(-1,1e10);
	if(hi<0)
	{
		cout << "0" << endl;
		return 0;
	}
	cout << hi-lo+1 << endl;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid)==0)
			lo=mid;
		else
			hi=mid-1;
	}
	lo++;
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid)==1)
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>m)
		{
			cout << "0" << endl;
			return 0;
		}
	}
	int hi= binsearch2(0,1e10);
	int lo= binsearch(-1,1e10);
	int xx= check1(lo);
	int yy= check2(hi);
	if(xx==1 && yy==1)
		cout << hi-lo+1 << endl;
	else
		cout << "0\n";
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid)==0)
			lo=mid;
		else
			hi=mid-1;
	}
	lo++;
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid)==1)
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>m)
		{
			cout << "0" << endl;
			return 0;
		}
	}
	int hi= binsearch2(0,1e10);
	int lo= binsearch(-1,1e10);
	cout << hi << " " << lo << endl;
	cout << hi-lo+1 << endl;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

const int N=1e3 + 5;
int a[N];
int n,m;

int check1(int k)
{
	int sum =k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum<0)
			return 0;
	}
	return 1;
}

int check2(int k)
{
	int sum=k;
	int i;
	for(i=1;i<=n;i++)
	{
		sum += a[i];
		if(sum>m)
		{
			return 0;
		}
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check1(mid)==0)
			lo=mid;
		else
			hi=mid-1;
	}
	lo++;
	return lo;
}

int binsearch2(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)>>1;// makes 7-4, 8-4,3-2 ,1-1.. adding 1 dont forget
		if(check2(mid)==1)
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n;
	cin >> m;
	int i;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>m)
		{
			cout << "0" << endl;
			return 0;
		}
	}
	int hi= binsearch2(0,1e10);
	int lo= binsearch(-1,1e10);
	if(lo==hi)
	{
		cout << "0" << endl;
		return 0;
	}
	cout << hi-lo+1 << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void engine(){
    ll times, busCapasity, temp = 0,maxLeft = 0, maxRight = 0;
    cin >> times >> busCapasity;
    vector<ll> busStop(busCapasity);
    for(int t = 0; t < times; t++){
        cin >> busStop[t];
        if(temp > 0){
            if(busStop[t] > 0){
                temp += busStop[t];
            }
            else{
                maxRight = max(maxRight, temp);
                temp += busStop[t];
            }
        }
        else{
            if(busStop[t] > 0){
                maxLeft = min(maxLeft, temp);
                temp += busStop[t];
            }
            else{
                temp += busStop[t];
            }
        }
        if(t == times - 1){
            if(temp > 0){
                maxRight = max(maxRight, temp);
            }
            else{
                maxLeft = min(temp, maxLeft);
            }
        }
    }
    if(-maxLeft > busCapasity or maxRight > busCapasity){
        cout << 0;
    }
    else{
        cout << maxLeft + busCapasity - maxRight + 1;
    }
}

int main(){
  engine();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void engine(){
    ll times, busCapasity, temp = 0,maxLeft = 0, maxRight = 0;
    cin >> times >> busCapasity;
    vector<int> busStop(busCapasity);
    for(ll t = 0; t < times; t++){
        cin >> busStop[t];
        if(temp > 0){
            if(busStop[t] > 0){
                temp += busStop[t];
            }
            else{
                maxRight = max(maxRight, temp);
                temp += busStop[t];
            }
        }
        else{
            if(busStop[t] > 0){
                maxLeft = min(maxLeft, temp);
                temp += busStop[t];
            }
            else{
                temp += busStop[t];
            }
        }
        if(t == times - 1){
            if(temp > 0){
                maxRight = max(maxRight, temp);
            }
            else{
                maxLeft = min(temp, maxLeft);
            }
        }
    }
    if(-maxLeft > busCapasity or maxRight > busCapasity){
        cout << 0;
    }
    else{
        cout << maxLeft + busCapasity - maxRight + 1;
    }
}

int main(){
  engine();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void engine(){
    ll times, busCapasity, temp = 0,maxLeft = 0, maxRight = 0,a;
    cin >> times >> busCapasity;
    for(ll t = 0; t < times; t++){
        cin >> a;
        if(temp < maxLeft) maxLeft = temp;
        if(temp > maxRight) maxRight = temp;
        }
        // else{
        //     if(busStop[t] > 0){
        //         maxLeft = min(maxLeft, temp);
        //         temp += busStop[t];
        //     }
        //     else{
        //         temp += busStop[t];
        //     }
        // }
        // if(t == times - 1){
        //     if(temp > 0){
        //         maxRight = max(maxRight, temp);
        //     }
        //     else{
        //         maxLeft = min(temp, maxLeft);
        //     }
        // }
    }
    if(maxLeft + busCapasity - maxRight + 1 > 0){
        cout << maxLeft + busCapasity - maxRight + 1;
    }
    else{
        cout << 0;
    }
}

int main(){
  engine();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

void engine(){
    int  times, busCapasity;
    ll temp = 0,maxLeft = 0, maxRight = 0;
    cin >> times >> busCapasity;
    vector<int> busStop(busCapasity);
    for(int t = 0; t < times; t++){
        cin >> busStop[t];
        if(temp > 0){
            if(busStop[t] > 0){
                temp += busStop[t];
            }
            else{
                maxRight = max(maxRight, temp);
                temp += busStop[t];
            }
        }
        else{
            if(busStop[t] > 0){
                maxLeft = min(maxLeft, temp);
                temp += busStop[t];
            }
            else{
                temp += busStop[t];
            }
        }
        if(t == times - 1){
            if(temp > 0){
                maxRight = max(maxRight, temp);
            }
            else{
                maxLeft = min(temp, maxLeft);
            }
        }
    }
    if(-maxLeft > busCapasity or maxRight > busCapasity){
        cout << 0;
    }
    else{
        cout << maxLeft + busCapasity - maxRight + 1;
    }
}

int main(){
  engine();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

void engine(){
    int  times, busCapasity,temp = 0,maxLeft = 0, maxRight = 0;
    bool isPositive;
    cin >> times >> busCapasity;
    vector<int> busStop(busCapasity);
    for(int t = 0; t < times; t++){
        cin >> busStop[t];
        if(temp > 0){
            if(busStop[t] > 0){
                temp += busStop[t];
            }
            else{
                maxRight = max(maxRight, temp);
                temp += busStop[t];
            }
        }
        else{
            if(busStop[t] > 0){
                maxLeft = min(maxLeft, temp);
                temp += busStop[t];
            }
            else{
                temp += busStop[t];
            }
        }
        if(t == times - 1){
            if(temp > 0){
                maxRight = max(maxRight, temp);
            }
            else{
                maxLeft = min(temp, maxLeft);
            }
        }
    }
    if(-maxLeft > busCapasity or maxRight > busCapasity){
        cout << 0;
    }
    else{
        cout << maxLeft + busCapasity - maxRight + 1;
    }
}

int main(){
  engine();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

void engine(){
    int  times, busCapasity,temp = 0,maxLeft = 0, maxRight = 0;
    bool isPositive;
    cin >> times >> busCapasity;
    vector<int> busStop(busCapasity);
    for(int t = 0; t < times; t++){
        cin >> busStop[t];
        if(temp > 0){
            if(busStop[t] > 0){
                temp += busStop[t];
            }
            else{
                maxRight = max(maxRight, temp);
                temp += busStop[t];
            }
        }
        else{
            if(busStop[t] > 0){
                maxLeft = min(maxLeft, temp);
                temp += busStop[t];
            }
            else{
                temp += busStop[t];
            }
        }
        if(t == times - 1){
            if(temp > 0){
                maxRight = max(maxRight, temp);
            }
            else{
                maxLeft = min(temp, maxLeft);
            }
        }
    }
    if(maxLeft > busCapasity or maxRight > busCapasity){
        cout << 0;
    }
    else{
        cout << maxLeft + busCapasity - maxRight + 1;
    }
}

int main(){
  engine();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void engine(){
    ll times, busCapasity, temp = 0,maxLeft = 0, maxRight = 0,a;
    cin >> times >> busCapasity;
    for(ll t = 0; t < times; t++){
        cin >> a;
        temp += a;
        if(temp < maxLeft) maxLeft = temp;
        if(temp > maxRight) maxRight = temp;
        }
        // else{
        //     if(busStop[t] > 0){
        //         maxLeft = min(maxLeft, temp);
        //         temp += busStop[t];
        //     }
        //     else{
        //         temp += busStop[t];
        //     }
        // }
        // if(t == times - 1){
        //     if(temp > 0){
        //         maxRight = max(maxRight, temp);
        //     }
        //     else{
        //         maxLeft = min(temp, maxLeft);
        //     }
        // }

    if(maxLeft + busCapasity - maxRight + 1 > 0){
        cout << maxLeft + busCapasity - maxRight + 1;
    }
    else{
        cout << 0;
    }
}

int main(){
  engine();
}


import java.util.*;
import java.io.*;
import java.lang.*;
public final class solution {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int tests = Integer.parseInt(br.readLine());
        while(tests>0){
            String input = br.readLine();
            String[] split = input.split(" ");
            int a = Integer.parseInt(split[0]);
            int b = Integer.parseInt(split[1]);
            int c = Integer.parseInt(split[2]);
            int n = Integer.parseInt(split[3]);
             int largest =0;

                if(a>b){
                    if(a>c){
                        largest=a;
                    } else{
                        largest =c;
                    }
                } else {
                    if(b>c){
                        largest = b;
                    } else{
                        largest =c;
                    }
                }
                if(a==b && b==c && c==a && (n%3==0)){
                     System.out.println("YES");
                }else if((n-(3*largest-a-b-c ))>=0){
                   if((n-(3*largest-a-b-c ))%3==0){
                    System.out.println("YES");
                } else{
                     System.out.println("NO");
                }
                }else {
                     System.out.println("NO");
                }

           tests--;
        }

    }
}


public final class solution {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int tests = Integer.parseInt(br.readLine());
        int largest =0;
        while(tests>0){
            String input = br.readLine();
            String[] split = input.split(" ");
            int a = Integer.parseInt(split[0]);
            int b = Integer.parseInt(split[1]);
            int c = Integer.parseInt(split[2]);
            int n = Integer.parseInt(split[3]);
             int largest =0;
            if(a==b && b==c && c==a && (n%3==0)){
                System.out.println("YES");
            } else{
                if(a>b){
                    if(a>c){
                        largest=a;
                    } else{
                        largest =c;
                    }
                } else {
                    if(b>c){
                        largest = b;
                    } else{
                        largest =c;
                    }
                }
                if((n-(3*largest-a-b-C ))%3==0){
                    System.out.println("YES");
                }
            }
            System.out.println("NO");
            tests--;
        }
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Question1294A {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt();
        while (n--!=0){
            int[] arr=new int[4];
            for(int i=0;i<4;i++){
                arr[i]=sc.nextInt();
            }
            Arrays.sort(arr,0,2);
            int x=arr[2]-arr[0];
            int y=arr[2]-arr[1];
            int ans=x+y;
            if(ans>arr[3]||((arr[3]-ans)%3)!=0){
                System.out.println("NO");
            }
            else if(ans==arr[3]||(arr[3]-ans)%3==0){
                System.out.println("YES");
            }
        }

    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Question1294A {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt();
        while (n--!=0){
            int[] arr=new int[4];
            for(int i=0;i<4;i++){
                arr[i]=sc.nextInt();
            }
            Arrays.sort(arr,0,2);
            int x=arr[2]-arr[0];
            int y=arr[2]-arr[1];
            int ans=x+y;
            if(ans>arr[3]||((arr[3]-ans)%3)!=0){
                System.out.println("NO");
            }
            if((arr[3]-ans)%3==0){
                System.out.println("YES");
            }
        }

    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Question1294A {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt();
        while (n--!=0){
            int[] arr=new int[4];
            for(int i=0;i<4;i++){
                arr[i]=sc.nextInt();
            }
            Arrays.sort(arr,0,2);
            int x=arr[2]-arr[0];
            int y=arr[2]-arr[1];
            int ans=x+y;
            if(ans>arr[3]||((arr[3]-ans)%3)!=0){
                System.out.println("NO");
            }
            else {
                System.out.println("YES");
            }
        }

    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Question1294A {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt();
        while (n--!=0){
            int[] arr=new int[4];
            for(int i=0;i<4;i++){
                arr[i]=sc.nextInt();
            }
            Arrays.sort(arr,0,3);
            int x=arr[2]-arr[0];
            int y=arr[2]-arr[1];
            int ans=x+y;
            if(ans>arr[3]||((arr[3]-ans)%3)!=0){
                System.out.println("NO");
            }
            else if(ans==arr[3]||(arr[3]-ans)%3==0){
                System.out.println("YES");
            }
        }

    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Question1294A {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt();
        while (n--!=0){
            int[] arr=new int[4];
            for(int i=0;i<4;i++){
                arr[i]=sc.nextInt();
            }
            Arrays.sort(arr,0,2);
            int x=arr[2]-arr[0];
            int y=arr[2]-arr[1];
            int ans=x+y;
            if(ans>arr[3]||((arr[3]-ans)%3)!=0){
                System.out.println("N0");
            }
            else {
                System.out.println("YES");
            }
        }

    }
}


//package codeforces;

import java.util.Scanner;

public class CollectingCoins {

    public static void main (String[] args) throws Exception
    {

//        System.out.println("-----------------------------");

        System.out.println("1");
        String s = "5\n" +
                "5 3 2 8\n" +
                "100 101 102 105\n" +
                "3 2 1 100000000\n" +
                "10 20 15 14\n" +
                "101 101 101 3";

        int T;
        Scanner scan = new Scanner(System.in);
//        Scanner scan = new Scanner(s);

        System.out.println("2");

        T = scan.nextInt();
        System.out.println("3");
        for (int t=0; t<T; ++t) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            int n = scan.nextInt();

            int total = a+b+c+n;

            int ABC = total/3;

            if (total == ABC*3 && ABC >= a && ABC >= b && ABC >= c) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }

}


package codeforces;

import java.util.Scanner;

public class CollectingCoins {

    public static void main (String[] args) throws Exception
    {

        System.out.println("-----------------------------");

        String s = "5\n" +
                "5 3 2 8\n" +
                "100 101 102 105\n" +
                "3 2 1 100000000\n" +
                "10 20 15 14\n" +
                "101 101 101 3";

        int T;
//        Scanner scan = new Scanner(System.in);
        Scanner scan = new Scanner(s);

        T = scan.nextInt();
        for (int t=0; t<T; ++t) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            int n = scan.nextInt();

            int total = a+b+c+n;

            int ABC = total/3;

            if (total == ABC*3 && ABC >= a && ABC >= b && ABC >= c) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }

}


//package codeforces;

import java.util.Scanner;

public class CollectingCoins {

    public static void main (String[] args) throws Exception
    {

//        System.out.println("-----------------------------");

        String s = "5\n" +
                "5 3 2 8\n" +
                "100 101 102 105\n" +
                "3 2 1 100000000\n" +
                "10 20 15 14\n" +
                "101 101 101 3";

        int T;
        Scanner scan = new Scanner(System.in);
//        Scanner scan = new Scanner(s);

        T = scan.nextInt();
        for (int t=0; t<T; ++t) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            int n = scan.nextInt();

            int total = a+b+c+n;

            int ABC = total/3;

            if (total == ABC*3 && ABC >= a && ABC >= b && ABC >= c) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }

}


package codeforces;

import java.util.Scanner;

public class CollectingCoins {

    public static void main (String[] args) throws Exception
    {

//        System.out.println("-----------------------------");

        String s = "5\n" +
                "5 3 2 8\n" +
                "100 101 102 105\n" +
                "3 2 1 100000000\n" +
                "10 20 15 14\n" +
                "101 101 101 3";

        int T;
        Scanner scan = new Scanner(System.in);
//        Scanner scan = new Scanner(s);

        T = scan.nextInt();
        for (int t=0; t<T; ++t) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            int n = scan.nextInt();

            int total = a+b+c+n;

            int ABC = total/3;

            if (total == ABC*3 && ABC >= a && ABC >= b && ABC >= c) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }

}


package codeforces;

import java.util.Scanner;

public class CollectingCoins {

    public static void main (String[] args) throws Exception
    {

//        System.out.println("-----------------------------");

        System.out.println("1");
        String s = "5\n" +
                "5 3 2 8\n" +
                "100 101 102 105\n" +
                "3 2 1 100000000\n" +
                "10 20 15 14\n" +
                "101 101 101 3";

        int T;
        Scanner scan = new Scanner(System.in);
//        Scanner scan = new Scanner(s);

        System.out.println("2");

        T = scan.nextInt();
        System.out.println("3");
        for (int t=0; t<T; ++t) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            int n = scan.nextInt();

            int total = a+b+c+n;

            int ABC = total/3;

            if (total == ABC*3 && ABC >= a && ABC >= b && ABC >= c) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }

}


import java.io.*;
import java.util.*;

public class Solution {

    private static void solve() throws Exception {

        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        int n = nextInt();

        int max = Math.max(a, Math.max(c, b));

        int coins = max - a + max - b + max - c;
        if (coins > n || (n - coins) % 3 != 0) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

    static BufferedReader br;
    static StringTokenizer st;

    public static void main(String[] args) throws Exception {

        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;

        int tests = nextInt();

        try {
            for (int i = 1; i <= tests; i++) {
                // System.out.print("Case #" + i + ": ");
                solve();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            br.close();
        }
    }

    static String nextToken() throws Exception {
        if (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    static String nextLine() throws Exception {
        return br.readLine();
    }

    static int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    static long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    static double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    private static void solve() throws Exception {

        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        int n = nextInt();

        int max = Math.max(a, Math.max(c, b));

        int coins = max - a + max - b + max - c;
        if (coins <= n && (n - coins) % 3 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    static BufferedReader br;
    static StringTokenizer st;

    public static void main(String[] args) throws Exception {

        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;

        int tests = nextInt();

        try {
            for (int i = 1; i <= tests; i++) {
                // System.out.print("Case #" + i + ": ");
                solve();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            br.close();
        }
    }

    static String nextToken() throws Exception {
        if (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    static String nextLine() throws Exception {
        return br.readLine();
    }

    static int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    static long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    static double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    private static void solve() throws Exception {

        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        int n = nextInt();

        if (a < b) {
            int t = b;
            b = a;
            a = t;
        }

        if (a < c) {
            int t = c;
            c = a;
            a = t;
        }

        int coins = a - c + a - b;
        if (coins <= n && (n - coins) % 3 == 0) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

    static BufferedReader br;
    static StringTokenizer st;

    public static void main(String[] args) throws Exception {

        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;

        int tests = nextInt();

        try {
            for (int i = 1; i <= tests; i++) {
                // System.out.print("Case #" + i + ": ");
                solve();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            br.close();
        }
    }

    static String nextToken() throws Exception {
        if (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    static String nextLine() throws Exception {
        return br.readLine();
    }

    static int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    static long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    static double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    private static void solve() throws Exception {

        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        int n = nextInt();

        if (a < b) {
            int t = b;
            b = a;
            a = t;
        }

        if (a < c) {
            int t = c;
            c = a;
            a = t;
        }

        int coins = a - c + a - b;
        if (coins <= n && (n - coins) % 3 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    static BufferedReader br;
    static StringTokenizer st;

    public static void main(String[] args) throws Exception {

        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;

        int tests = nextInt();

        try {
            for (int i = 1; i <= tests; i++) {
                // System.out.print("Case #" + i + ": ");
                solve();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            br.close();
        }
    }

    static String nextToken() throws Exception {
        if (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    static String nextLine() throws Exception {
        return br.readLine();
    }

    static int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    static long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    static double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}


import java.io.*;
public class GFG
 {
	public static void main (String[] args) throws IOException
	 {

	     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	     int t = Integer.parseInt(br.readLine());
	     while(t>0){
	         String line = br.readLine();
             String[] strs = line.trim().split("\\s+");

	         long a = Long.parseLong(strs[0]);
	         long b = Long.parseLong(strs[1]);
	         long c = Long.parseLong(strs[2]);
	         long d = Long.parseLong(strs[3]);

	         long max = Math.max(a, Math.max(b,c));
	         d = d - max-a+(max-b)+(max-c);
	         if(d%3==0)
	         System.out.println("YES");
	         else
	         System.out.println("NO");
	         t--;
	     }
	 }
}


import java.io.*;
public class GFG
 {
	public static void main (String[] args) throws IOException
	 {

	     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	     int t = Integer.parseInt(br.readLine());
	     while(t>0){
	         String line = br.readLine();
             String[] strs = line.trim().split("\\s+");

	         long a = Long.parseLong(strs[0]);
	         long b = Long.parseLong(strs[1]);
	         long c = Long.parseLong(strs[2]);
	         long d = Long.parseLong(strs[3]);

	         long max = Math.max(a, Math.max(b,c));
	         d = d - (max-a) - (max-b) - (max-c);
	         if(d%3==0&&d>=0)
	         System.out.println("YES");
	         else
	         System.out.println("NO");
	         t--;
	     }
	 }
}


import java.io.*;
public class GFG
 {
	public static void main (String[] args) throws IOException
	 {

	     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	     int t = Integer.parseInt(br.readLine());
	     while(t>0){
	         String line = br.readLine();
             String[] strs = line.trim().split("\\s+");

	         long a = Long.parseLong(strs[0]);
	         long b = Long.parseLong(strs[1]);
	         long c = Long.parseLong(strs[2]);
	         long d = Long.parseLong(strs[3]);

	         long max = Math.max(a, Math.max(b,c));
	         d = d - (max-a) - (max-b) - (max-c);
	         if(d%3==0)
	         System.out.println("YES");
	         else
	         System.out.println("NO");
	         t--;
	     }
	 }
}


import java.io.*;
public class GFG
 {
	public static void main (String[] args) throws IOException
	 {

	     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	     int t = Integer.parseInt(br.readLine());
	     while(t>0){
	         String line = br.readLine();
             String[] strs = line.trim().split("\\s+");

	         long a = Long.parseLong(strs[0]);
	         long b = Long.parseLong(strs[1]);
	         long c = Long.parseLong(strs[2]);
	         long d = Long.parseLong(strs[3]);

	         long max = Math.max(a, Math.max(b,c));
	         d = d - (max-a) - (max-b) - (max-c);
	         if(d%3==0&&d>0)
	         System.out.println("YES");
	         else
	         System.out.println("NO");
	         t--;
	     }
	 }
}


import java.io.*;
public class GFG
 {
	public static void main (String[] args) throws IOException
	 {

	     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	     int t = Integer.parseInt(br.readLine());
	     while(t>0){
	         String line = br.readLine();
             String[] strs = line.trim().split("\\s+");

	         long a = Long.parseLong(strs[0]);
	         long b = Long.parseLong(strs[1]);
	         long c = Long.parseLong(strs[2]);
	         long d = Long.parseLong(strs[3]);

	         long max = Math.max(a, Math.max(b,c));
	         d = d + max-a+(max-b)+(max-c);
	         if(d%3==0)
	         System.out.println("YES");
	         else
	         System.out.println("NO");
	         t--;
	     }
	 }
}


import java.util.Scanner;
 public class Myproject {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
         int t=s.nextInt();
         while(t>0)
         {
             int flag=1;
                      long a=s.nextLong();
                      long b=s.nextLong();
                      long c=s.nextLong();
                      long n=s.nextLong();
           if(((a+b+c+n)%3)==0)
           System.out.println("YES");
           else
              System.out.println("NO");

           t--;

         }
    }
}


package myproject;

import java.util.Scanner;
public class Myproject {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
         int t=s.nextInt();
         while(t>0)
         {
             int flag=1;
                      long a=s.nextLong();
                      long b=s.nextLong();
                      long c=s.nextLong();
                      long n=s.nextLong();
           if(((a+b+c+n)%3)==0)
           System.out.println("YES");
           else
              System.out.println("NO");

           t--;

         }
    }
}


import java.util.Scanner;
 public class Myproject {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
         int t=s.nextInt();
         while(t>0)
         {
                  int flag=1;
                      long a=s.nextLong();
                      long b=s.nextLong();
                      long c=s.nextLong();
                      long n=s.nextLong();
           if(((a+b+c+n)%3)==0)
           {
                    long each=(a+b+c+n)/3;
                    long A=each-a;
                    long B=each-b;
                    long C=each-c;
                    if(A+B+C==n&&(A>=0&&B>=0&&C>=0))
              System.out.println("YES");
              else
              System.out.println("NO");
           }
           else
              System.out.println("NO");

           t--;

         }
    }
}


package myproject;

import java.util.Scanner;
public class Myproject {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
         int t=s.nextInt();
         while(t>0)
         {
             int flag=1;
                      int a=s.nextInt();
         int b=s.nextInt();
         int c=s.nextInt();
         int n=s.nextInt();
           if(((a+b+c+n)%3)==0)
           System.out.println("YES");
           else
              System.out.println("NO");

           t--;

         }
    }
}


import java.util.Scanner;
 public class Myproject {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
         int t=s.nextInt();
         while(t>0)
         {
                  int flag=1;
                      long a=s.nextLong();
                      long b=s.nextLong();
                      long c=s.nextLong();
                      long n=s.nextLong();
           if(((a+b+c+n)%3)==0)
           {
                    long each=(a+b+c+n)/3;
                    long A=each-a;
                    long B=each-b;
                    long C=each-c;
                    if(A+B+C!=n)
              System.out.println("NO");
           }
           else
              System.out.println("NO");

           t--;

         }
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0)
        {
            int a=sc.nextInt();
            int b=sc.nextInt();
            int c=sc.nextInt();
            int n=sc.nextInt();
            int sum=(a+b+c+n);
            if((sum%3)==0 && n>=3)
            	System.out.println("YES");
            else
            	System.out.println("NO");
        }
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0)
        {
            int max = Integer.MIN_VALUE;
            int a=sc.nextInt();
            if(a>max)
                max = a;
            int b=sc.nextInt();
            if(b>max)
                max = b;
            int c=sc.nextInt();
            if(c>max)
                max = c;
            int n=sc.nextInt();
            int sum=(max-a)+(max-b)+(max-c);
            n-=sum;
            if(n>=0 && (n%3)==0)
            	System.out.println("YES");
            else
            	System.out.println("NO");
        }
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0)
        {
            int a=sc.nextInt();
            int b=sc.nextInt();
            int c=sc.nextInt();
            int n=sc.nextInt();
            a%=3;
            b%=3;
            c%=3;
            int sum=(a+b+c+n);
            if((sum%3)==0)
            	System.out.println("YES");
            else
            	System.out.println("NO");
        }
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0)
        {
            int a=sc.nextInt();
            int b=sc.nextInt();
            int c=sc.nextInt();
            int n=sc.nextInt();
            int sum=(a+b+c+n);
            if((sum%3)==0)
            	System.out.println("YES");
            else
            	System.out.println("NO");
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.sql.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class A {
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}

class Solution {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = new StringTokenizer("");

    String next() throws IOException {
        if (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    void nextInt(Integer[] a) throws IOException {
        for (Integer num : a) {
            num = nextInt();
        }
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    void solve() throws IOException {
        Integer t;
        t = nextInt();
        while (t-- >= 0) {
            Integer n;
            Integer a[] = new Integer[3];
            a[0] = nextInt();
            a[1] = nextInt();
            a[2] = nextInt();
            n = nextInt();
            Arrays.sort(a, Collections.reverseOrder());
            Integer minN = 2 * a[0] - a[1] - a[2];
            if (n >= minN && (n - minN) % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.sql.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class A {
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}

class Solution {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = new StringTokenizer("");

    String next() throws IOException {
        if (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    void nextInt(Integer[] a) throws IOException {
        for (Integer num : a) {
            num = nextInt();
        }
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    void solve() throws IOException {
        Integer t;
        t = nextInt();
        while (t-- > 0) {
            Integer n;
            Integer a[] = new Integer[3];
            a[0] = nextInt();
            a[1] = nextInt();
            a[2] = nextInt();
            n = nextInt();
            Arrays.sort(a, Collections.reverseOrder());
            Integer minN = 2 * a[0] - a[1] - a[2];
            if (n >= minN && (n - minN) % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


package div3.r615;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.sql.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class A {
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}

class Solution {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = new StringTokenizer("");

    String next() throws IOException {
        if (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    void nextInt(Integer[] a) throws IOException {
        for (Integer num : a) {
            num = nextInt();
        }
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    void solve() throws IOException {
        Integer t;
        t = nextInt();
        while (t-- >= 0) {
            Integer n;
            Integer a[] = new Integer[3];
            a[0] = nextInt();
            a[1] = nextInt();
            a[2] = nextInt();
            n = nextInt();
            Arrays.sort(a, Collections.reverseOrder());
            Integer minN = 2 * a[0] - a[1] - a[2];
            if (n >= minN && (n - minN) % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


package div3.r615;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.sql.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class A {
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}

class Solution {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = new StringTokenizer("");

    String next() throws IOException {
        if (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    void nextInt(Integer[] a) throws IOException {
        for (Integer num : a) {
            num = nextInt();
        }
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    void solve() throws IOException {
        Integer t;
        t = nextInt();
        while (t-- > 0) {
            Integer n;
            Integer a[] = new Integer[3];
            a[0] = nextInt();
            a[1] = nextInt();
            a[2] = nextInt();
            n = nextInt();
            Arrays.sort(a, Collections.reverseOrder());
            Integer minN = 2 * a[0] - a[1] - a[2];
            if (n >= minN && (n - minN) % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader bf =  new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader bf =  new BufferedReader(new FileReader("p.txt"));

		StringTokenizer tk = new StringTokenizer(bf.readLine());

		int casos = Integer.parseInt(tk.nextToken());

		for (int i = 0; i < casos; i++) {

			int nums[] = new int[3];
			tk = new StringTokenizer(bf.readLine());
			nums[0] = Integer.parseInt(tk.nextToken());
			nums[1] = Integer.parseInt(tk.nextToken());
			nums[2] = Integer.parseInt(tk.nextToken());
			int n = Integer.parseInt(tk.nextToken());
			Arrays.sort(nums);

			for (int j = 0; j < 2; j++) {

				int dif = nums[2]-nums[j];
				nums[j] += dif;
				n = n - dif;

			}

			if ((n%3==0)&&(n>=0)) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		//BufferedReader bf =  new BufferedReader(new InputStreamReader(System.in));
		BufferedReader bf =  new BufferedReader(new FileReader("p.txt"));

		StringTokenizer tk = new StringTokenizer(bf.readLine());

		int casos = Integer.parseInt(tk.nextToken());

		for (int i = 0; i < casos; i++) {

			int nums[] = new int[3];
			tk = new StringTokenizer(bf.readLine());
			nums[0] = Integer.parseInt(tk.nextToken());
			nums[1] = Integer.parseInt(tk.nextToken());
			nums[2] = Integer.parseInt(tk.nextToken());
			int n = Integer.parseInt(tk.nextToken());
			Arrays.sort(nums);

			for (int j = 0; j < 2; j++) {

				int dif = nums[2]-nums[j];
				nums[j] += dif;
				n = n - dif;

			}

			if ((n%3==0)||(n==0)) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader bf =  new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader bf =  new BufferedReader(new FileReader("p.txt"));

		StringTokenizer tk = new StringTokenizer(bf.readLine());

		int casos = Integer.parseInt(tk.nextToken());

		for (int i = 0; i < casos; i++) {

			int nums[] = new int[3];
			tk = new StringTokenizer(bf.readLine());
			nums[0] = Integer.parseInt(tk.nextToken());
			nums[1] = Integer.parseInt(tk.nextToken());
			nums[2] = Integer.parseInt(tk.nextToken());
			int n = Integer.parseInt(tk.nextToken());
			Arrays.sort(nums);

			for (int j = 0; j < 2; j++) {

				int dif = nums[2]-nums[j];
				nums[j] += dif;
				n = n - dif;

			}

			if ((n%3==0)||(n==0)) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		//BufferedReader bf =  new BufferedReader(new InputStreamReader(System.in));
		BufferedReader bf =  new BufferedReader(new FileReader("p.txt"));

		StringTokenizer tk = new StringTokenizer(bf.readLine());

		int casos = Integer.parseInt(tk.nextToken());

		for (int i = 0; i < casos; i++) {

			int nums[] = new int[3];
			tk = new StringTokenizer(bf.readLine());
			nums[0] = Integer.parseInt(tk.nextToken());
			nums[1] = Integer.parseInt(tk.nextToken());
			nums[2] = Integer.parseInt(tk.nextToken());
			int n = Integer.parseInt(tk.nextToken());
			Arrays.sort(nums);

			for (int j = 0; j < 2; j++) {

				int dif = nums[2]-nums[j];
				nums[j] += dif;
				n = n - dif;

			}

			if ((n%3==0)&&(n>0)) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader bf =  new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader bf =  new BufferedReader(new FileReader("p.txt"));

		StringTokenizer tk = new StringTokenizer(bf.readLine());

		int casos = Integer.parseInt(tk.nextToken());

		for (int i = 0; i < casos; i++) {

			int nums[] = new int[3];
			tk = new StringTokenizer(bf.readLine());
			nums[0] = Integer.parseInt(tk.nextToken());
			nums[1] = Integer.parseInt(tk.nextToken());
			nums[2] = Integer.parseInt(tk.nextToken());
			int n = Integer.parseInt(tk.nextToken());
			Arrays.sort(nums);

			for (int j = 0; j < 2; j++) {

				int dif = nums[2]-nums[j];
				nums[j] += dif;
				n = n - dif;

			}

			if ((n%3==0)&&(n>0)) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.Scanner;

/**
 *
 * @author cavca
 */
public class P1294A {

    public static void main(String[] args) {
        Scanner leer = new Scanner(System.in);

        int veces = leer.nextInt();
        boolean repartir[] = new boolean[veces];
        int mayor;
        int totalM;

        for (int i = 0; i < veces; i++) {
            totalM = 0;
            mayor = 0;
            for (int j = 0; j < 4; j++) {
                totalM+=leer.nextInt();
            }

            repartir[i]=totalM%3==0;
        }

        for(boolean b:repartir){
            System.out.println(b ? "YES" : "NO");
        }
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package codeforces;

import java.util.Scanner;

/**
 *
 * @author cavca
 */
public class P1294A {

    public static void main(String[] args) {
        Scanner leer = new Scanner(System.in);

        int veces = leer.nextInt();
        boolean repartir[] = new boolean[veces];
        int mayor;
        int totalM;

        for (int i = 0; i < veces; i++) {
            totalM = 0;
            mayor = 0;
            for (int j = 0; j < 4; j++) {
                totalM+=leer.nextInt();
            }

            repartir[i]=totalM%3==0;
        }

        for(boolean b:repartir){
            System.out.println(b ? "YES" : "NO");
        }
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.Scanner;

/**
 *
 * @author cavca
 */
public class P1294A {

    public static void main(String[] args) {
        Scanner leer = new Scanner(System.in);

        int veces = leer.nextInt();
        boolean repartir[] = new boolean[veces];
        int mayor;
        int totalM;

        for (int i = 0; i < veces; i++) {
            totalM = 0;
            mayor = 0;
            for (int j = 0; j < 4; j++) {
                int a=leer.nextInt();
                totalM+=a;
                if(a>mayor && j<3){
                    mayor=a;
                }
            }

            repartir[i]=totalM%3==0 && mayor<=(totalM/3);
        }

        for(boolean b:repartir){
            System.out.println(b ? "YES" : "NO");
        }
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.Scanner;

/**
 *
 * @author cavca
 */
public class P1294A {

    public static void main(String[] args) {
        Scanner leer = new Scanner(System.in);

        int veces = leer.nextInt();
        boolean repartir[] = new boolean[veces];
        int mayor;
        int totalM;

        for (int i = 0; i < veces; i++) {
            totalM = 0;
            mayor = 0;
            for (int j = 0; j < 4; j++) {
                int a=leer.nextInt();
                totalM+=a;
                if(a>mayor && j<3){
                    mayor=a;
                }
            }

            repartir[i]=totalM%3==0 && mayor<totalM/3;
        }

        for(boolean b:repartir){
            System.out.println(b ? "YES" : "NO");
        }
    }
}


import java.util.Scanner;

public class Task1 {

    static long a;
    static long a1;
    static long b;
    static long b1;
    static long c;
    static long c1;
    static long n;
    static long k;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();

        for (int i = 0; i < t; i++) {

            a = scanner.nextInt();
            b = scanner.nextInt();
            c = scanner.nextInt();
            n = scanner.nextInt();

            k = a + b + c + n;
            if (k % 3 == 0) {
                a1 = k / 3 - a;
                b1 = k / 3 - b;
                c1 = k / 3 - c;
                if (a1 + a == b1 + b && b1 + b == c1 + c) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }
            } else {
                System.out.println("NO");
            }
        }
    }
}


package Codeforces;

import java.util.Scanner;

public class Task1 {

    static long a;
    static long b;
    static long c;
    static long n;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();

        while (t != 0) {
            a = scanner.nextInt();
            b = scanner.nextInt();
            c = scanner.nextInt();
            n = scanner.nextInt();

            if ((a + b + c + n) % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

            t--;
        }

    }
}


import java.util.Scanner;

public class Task1 {

    static long a;
    static long a1;
    static long b;
    static long b1;
    static long c;
    static long c1;
    static long n;
    static long k;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();

        for (int i = 0; i < t; i++) {

            a = scanner.nextInt();
            b = scanner.nextInt();
            c = scanner.nextInt();
            n = scanner.nextInt();

            k = a + b + c + n;
            if (k % 3 == 0) {
                a1 = k / 3 - a;
                b1 = k / 3 - b;
                c1 = k / 3 - c;
                if (a1 >= 0 && b1 >= 0 && c1 >= 0) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }
            } else {
                System.out.println("NO");
            }
        }
    }
}


package Codeforces;

import java.util.Scanner;

public class Task1 {

    static int a = 0;
    static int b;
    static int c;
    static int n;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();

        while (t != 0) {
            a = scanner.nextInt();
            b = scanner.nextInt();
            c = scanner.nextInt();
            n = scanner.nextInt();

            if ((a + b + c + n) % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

            t--;
        }

    }
}


import java.util.Scanner;

public class Task1 {

    static long a;
    static long b;
    static long c;
    static long n;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();

        while (t != 0) {
            a = scanner.nextInt();
            b = scanner.nextInt();
            c = scanner.nextInt();
            n = scanner.nextInt();

            if ((a + b + c + n) % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

            t--;
        }

    }
}


//package cfround615;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	/** Class for buffered reading int and double values */
	static class Reader {
	    static BufferedReader reader;
	    static StringTokenizer tokenizer;

	    /** call this method to initialize reader for InputStream */
	    static void init(InputStream input) {
	        reader = new BufferedReader(
	                     new InputStreamReader(input) );
	        tokenizer = new StringTokenizer("");
	    }

	    /** get next word */
	    static String next() throws IOException {
	        while ( ! tokenizer.hasMoreTokens() ) {
	            //TODO add check for eof if necessary
	            tokenizer = new StringTokenizer(
	                   reader.readLine() );
	        }
	        return tokenizer.nextToken();
	    }

	    static int nextInt() throws IOException {
	        return Integer.parseInt( next() );
	    }

	    static double nextDouble() throws IOException {
	        return Double.parseDouble( next() );
	    }
	    static long nextLong() throws IOException{
	    	return Long.parseLong(next());
	    }
	}

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		Reader.init(System.in);
		int t = Reader.nextInt();
		for(int i1=0;i1<t;i1++){
			int a = Reader.nextInt();
			int b = Reader.nextInt();
			int c = Reader.nextInt();
			int n = Reader.nextInt();
			int sum = a+b+c+n;
			if(sum%3==0){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}

	}
}


//package cfround615;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	/** Class for buffered reading int and double values */
	static class Reader {
	    static BufferedReader reader;
	    static StringTokenizer tokenizer;

	    /** call this method to initialize reader for InputStream */
	    static void init(InputStream input) {
	        reader = new BufferedReader(
	                     new InputStreamReader(input) );
	        tokenizer = new StringTokenizer("");
	    }

	    /** get next word */
	    static String next() throws IOException {
	        while ( ! tokenizer.hasMoreTokens() ) {
	            //TODO add check for eof if necessary
	            tokenizer = new StringTokenizer(
	                   reader.readLine() );
	        }
	        return tokenizer.nextToken();
	    }

	    static int nextInt() throws IOException {
	        return Integer.parseInt( next() );
	    }

	    static double nextDouble() throws IOException {
	        return Double.parseDouble( next() );
	    }
	    static long nextLong() throws IOException{
	    	return Long.parseLong(next());
	    }
	}

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		Reader.init(System.in);
		int t = Reader.nextInt();
		for(int i1=0;i1<t;i1++){
			int a = Reader.nextInt();
			int b = Reader.nextInt();
			int c = Reader.nextInt();
			int n = Reader.nextInt();
			int sum = a+b+c+n;
			if(n<0){
				System.out.println("NO");
			}
			else{
				if(sum%3==0){
					int each = sum/3;
					int A = each -a;
					int B = each -b;
					int C = each -c;
					if(A+B+C == n){
						System.out.println("YES");
					}
					else{
						System.out.println("NO");
					}

				}
				else{
					System.out.println("NO");
				}
			}
		}
	}
}


//package cfround615;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	/** Class for buffered reading int and double values */
	static class Reader {
	    static BufferedReader reader;
	    static StringTokenizer tokenizer;

	    /** call this method to initialize reader for InputStream */
	    static void init(InputStream input) {
	        reader = new BufferedReader(
	                     new InputStreamReader(input) );
	        tokenizer = new StringTokenizer("");
	    }

	    /** get next word */
	    static String next() throws IOException {
	        while ( ! tokenizer.hasMoreTokens() ) {
	            //TODO add check for eof if necessary
	            tokenizer = new StringTokenizer(
	                   reader.readLine() );
	        }
	        return tokenizer.nextToken();
	    }

	    static int nextInt() throws IOException {
	        return Integer.parseInt( next() );
	    }

	    static double nextDouble() throws IOException {
	        return Double.parseDouble( next() );
	    }
	    static long nextLong() throws IOException{
	    	return Long.parseLong(next());
	    }
	}

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		Reader.init(System.in);
		int t = Reader.nextInt();
		for(int i1=0;i1<t;i1++){
			int a = Reader.nextInt();
			int b = Reader.nextInt();
			int c = Reader.nextInt();
			int n = Reader.nextInt();
			int sum = a+b+c+n;
			if(n<0){
				System.out.println("NO");
			}
			else{
				if(sum%3==0){
					int max = Math.max(Math.max(a, b),c);
					if(max>n){
						System.out.println("NO");
					}
					else{
						System.out.println("YES");
					}

				}
				else{
					System.out.println("NO");
				}
			}
		}
	}
}


//package cfround615;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	/** Class for buffered reading int and double values */
	static class Reader {
	    static BufferedReader reader;
	    static StringTokenizer tokenizer;

	    /** call this method to initialize reader for InputStream */
	    static void init(InputStream input) {
	        reader = new BufferedReader(
	                     new InputStreamReader(input) );
	        tokenizer = new StringTokenizer("");
	    }

	    /** get next word */
	    static String next() throws IOException {
	        while ( ! tokenizer.hasMoreTokens() ) {
	            //TODO add check for eof if necessary
	            tokenizer = new StringTokenizer(
	                   reader.readLine() );
	        }
	        return tokenizer.nextToken();
	    }

	    static int nextInt() throws IOException {
	        return Integer.parseInt( next() );
	    }

	    static double nextDouble() throws IOException {
	        return Double.parseDouble( next() );
	    }
	    static long nextLong() throws IOException{
	    	return Long.parseLong(next());
	    }
	}

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		Reader.init(System.in);
		int t = Reader.nextInt();
		for(int i1=0;i1<t;i1++){
			int a = Reader.nextInt();
			int b = Reader.nextInt();
			int c = Reader.nextInt();
			int n = Reader.nextInt();
			int sum = a+b+c+n;
			if(n<0){
				System.out.println("NO");
			}
			else{
				if(sum%3==0){
					int max = Math.max(Math.max(a, b),c);
					if(max>n){
						if(a==b && b==c && a==c){
							System.out.println("YES");
						}
						else{
							System.out.println("NO");
						}
					}
					else{
						System.out.println("YES");
					}

				}
				else{
					System.out.println("NO");
				}
			}
		}
	}
}


//package cfround615;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	/** Class for buffered reading int and double values */
	static class Reader {
	    static BufferedReader reader;
	    static StringTokenizer tokenizer;

	    /** call this method to initialize reader for InputStream */
	    static void init(InputStream input) {
	        reader = new BufferedReader(
	                     new InputStreamReader(input) );
	        tokenizer = new StringTokenizer("");
	    }

	    /** get next word */
	    static String next() throws IOException {
	        while ( ! tokenizer.hasMoreTokens() ) {
	            //TODO add check for eof if necessary
	            tokenizer = new StringTokenizer(
	                   reader.readLine() );
	        }
	        return tokenizer.nextToken();
	    }

	    static int nextInt() throws IOException {
	        return Integer.parseInt( next() );
	    }

	    static double nextDouble() throws IOException {
	        return Double.parseDouble( next() );
	    }
	    static long nextLong() throws IOException{
	    	return Long.parseLong(next());
	    }
	}

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		Reader.init(System.in);
		int t = Reader.nextInt();
		for(int i1=0;i1<t;i1++){
			int a = Reader.nextInt();
			int b = Reader.nextInt();
			int c = Reader.nextInt();
			int n = Reader.nextInt();
			int sum = a+b+c+n;
			if(n<0){
				System.out.println("NO");
			}
			else{
				if(sum%3==0){
					int each = sum/3;
					int A = Math.abs(each-a);
					int B = Math.abs(each-b);
					int C = Math.abs(each-c);
					if(A+B+C == n){
						System.out.println("YES");
					}
					else{
						System.out.println("NO");
					}

				}
				else{
					System.out.println("NO");
				}
			}
		}
	}
}


import java.util.Arrays;
import java.util.Scanner;

/**
 * CF-one
 */
public class CFone {
    private static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        int t = in.nextInt();
        for(int i = 0; i < t; i++){
            boolean check = check(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt());
            if(check)
                System.out.println("YES");
            else
            System.out.println("NO");
        }
    }

    private static boolean check(int a, int b, int c, int n){
        int[] arr = new int[3];
        arr[0] = a;
        arr[1] = b;
        arr[2] = c;
        Arrays.sort(arr);
            n = n - (arr[2] - arr[0]);
            n = n - (arr[2] - arr[1]);
            arr[0] = arr[2];
            arr[1] = arr[2];

            if(arr[0] == arr[1] && arr[1] == arr[2] && n >= 0 && n % 3 == 0)
                return true;
            return false;
    }
}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();

            Arrays.sort(a);
            boolean q = true;
            if(n == 0)
                break;
            for(; n > 0;){
                if(a[1] - a[0] < n && a[1] - a[0] != 0){
                    n = n - (a[1] - a[0]);
                    a[0] = a[1];

                }
                else if (a[1] - a[0] == 0 && a[2] - a[1] < n && a[2] - a[1] != 0){
                    n = n - (a[2] - a[1]);
                    a[1] = a[2];

                }
                else if(a[1] == a[2] && a[2] == a[0] && n % 3 == 0)
                    break;
                else{
                    System.out.println("NO");
                    q = false;
                    break;
                }
                Arrays.sort(a);
            }
            if(q){
            if(a[0] == a[1] && a[1] == a[2])
                System.out.println("YES");
            else
            System.out.println("NO");
            }
            q=true;

        }
    }

}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();
            Arrays.sort(a);
            int count = 0;
            for(int j = 0; count < 3; j++){
                a[2]--;
                a[0]++;
                Arrays.sort(a);
                if(a[0] == a[1] || a[1] == a[2])
                    count++;
            }
            Arrays.sort(a);
            if(a[1] == a[0] && a[1] == a[2]){
                if(n % 3 == 0)
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }

            else if(a[1] == a[0]){
                if(n % 3 == 2)
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
            else if (a[1] == a[0]){
                if(n % 3 == 1)
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }

}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();
            Arrays.sort(a);
            int count = 0;
            for(int j = 0; count < 3; j++){
                a[2]--;
                a[0]++;
                Arrays.sort(a);
                if(a[0] == a[1] || a[1] == a[2])
                    count++;
            }
            Arrays.sort(a);
            if(a[1] == a[0] && a[1] == a[2]){
                if(n % 3 == 0)
                    System.out.print("YES");
                else
                    System.out.print("NO");
            }

            else if(a[1] == a[0]){
                if(n % 3 == 2)
                    System.out.print("YES");
                else
                    System.out.print("NO");
            }
            else if (a[1] == a[0]){
                if(n % 3 == 1)
                    System.out.print("YES");
                else
                    System.out.print("NO");
            }
        }
    }

}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();
            Arrays.sort(a);
            for(; n > 0; n--){
                a[0]++;
                Arrays.sort(a);
            }
            if(a[0] == a[1] && a[1] == a[2])
                System.out.println("YES");
            else
            System.out.println("NO");

        }
    }

}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();
            Arrays.sort(a);
            boolean q = true;
            for(; n > 0;){
                if(a[1] - a[0] < n && a[1] - a[0] != 0){
                    n = n - (a[1] - a[0]);
                    a[0] = a[1];

                }
                else if (a[1] - a[0] == 0 && a[2] - a[1] < n && a[2] - a[1] != 0){
                    n = n - (a[2] - a[1]);
                    a[1] = a[2];

                }
                else if(a[1] == a[2] && a[2] == a[0] && n % 3 == 0)
                    break;
                else{
                    System.out.println("NO");
                    q = false;
                    break;
                }
                Arrays.sort(a);
            }
            if(q){
            if(a[0] == a[1] && a[1] == a[2])
                System.out.println("YES");
            else
            System.out.println("NO");
            }
            q=true;

        }
    }

}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();
            int qwe = a[0] + a[1] + a[2];
            qwe = qwe % 3;
            int zxc = n % 3;
            if((qwe + zxc) % 3 == 0)
                System.out.println("YES");
            else
            System.out.println("NO");
        }
    }

}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();
            if(n == 0){
                if(a[0] == a[1] && a[1] == a[2])
                System.out.println("YES");
            else
            System.out.println("NO");
            continue;
            }
            Arrays.sort(a);
            boolean q = true;
            for(; n > 0;){
                if(a[1] - a[0] < n && a[1] - a[0] != 0){
                    n = n - (a[1] - a[0]);
                    a[0] = a[1];

                }
                else if (a[1] - a[0] == 0 && a[2] - a[1] < n && a[2] - a[1] != 0){
                    n = n - (a[2] - a[1]);
                    a[1] = a[2];

                }
                else if(a[1] == a[2] && a[2] == a[0] && n % 3 == 0)
                    break;
                else{
                    System.out.println("NO");
                    q = false;
                    break;
                }
                Arrays.sort(a);
            }
            if(q){
            if(a[0] == a[1] && a[1] == a[2])
                System.out.println("YES");
            else
            System.out.println("NO");
            }
            q=true;

        }
    }

}


/**
 * one
 */
import java.util.Arrays;
import java.util.Scanner;
public class one {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] a = new int[3];
        for(int i = 0; i < t; i++){
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            int n = in.nextInt();
            if(n == 0)
                break;
            Arrays.sort(a);
            boolean q = true;
            for(; n > 0;){
                if(a[1] - a[0] < n && a[1] - a[0] != 0){
                    n = n - (a[1] - a[0]);
                    a[0] = a[1];

                }
                else if (a[1] - a[0] == 0 && a[2] - a[1] < n && a[2] - a[1] != 0){
                    n = n - (a[2] - a[1]);
                    a[1] = a[2];

                }
                else if(a[1] == a[2] && a[2] == a[0] && n % 3 == 0)
                    break;
                else{
                    System.out.println("NO");
                    q = false;
                    break;
                }
                Arrays.sort(a);
            }
            if(q){
            if(a[0] == a[1] && a[1] == a[2])
                System.out.println("YES");
            else
            System.out.println("NO");
            }
            q=true;

        }
    }

}


import java.util.Arrays;
import java.util.Scanner;

public class Div3 {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while (t-- > 0) {
			long a[] = new long[3], sum = 0, max = 0;
			for(int i=0;i<3;i++) {
				a[i] = in.nextLong();
				sum = sum + a[i];
				if (a[i] > max) max = a[i];
			}

			long n = in.nextLong();
			sum = sum + n;
			if (sum % 3 != 0) {
				System.out.println("NO");
			} else {
				Arrays.parallelSort(a);
				n = n - (a[2] - a[0]);
				n = n - (a[2] - a[1]);
				if (n >= 0 && n % 3 == 0) System.out.println("YES");
				else System.out.println("NO");
			}
		}
		in.close();
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class Div3 {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while (t-- > 0) {
			long a[] = new long[3], sum = 0, max = 0;
			for(int i=0;i<3;i++) {
				a[i] = in.nextLong();
				sum = sum + a[i];
				if (a[i] > max) max = a[i];
			}

			long n = in.nextLong();
			sum = sum + n;
			if (sum % 3 != 0) {
				System.out.println("NO");
			} else {
				Arrays.parallelSort(a);
				n = n - (a[2] - a[0]);
				n = n - (a[2] - a[1]);
				if (n >= 0 || n % 3 == 0) System.out.println("YES");
				else System.out.println("NO");
			}
		}
		in.close();
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class Div3 {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while (t-- > 0) {
			long a[] = new long[3], sum = 0, max = 0;
			for(int i=0;i<3;i++) {
				a[i] = in.nextLong();
				sum = sum + a[i];
				if (a[i] > max) max = a[i];
			}

			long n = in.nextLong();
			sum = sum + n;
			if (sum % 3 != 0) {
				System.out.println("NO");
			} else {
				Arrays.parallelSort(a);
				n = n - (a[2] - a[0]);
				n = n - (a[2] - a[1]);
				if (n % 3 == 0) System.out.println("YES");
				else System.out.println("NO");
			}
		}
		in.close();
	}

}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * Pick questions that you love and solve them with love, try to get AC in one
 * go with cleanest code Just one thing to keep in mind these questions should
 * be out of your reach, which make you step out of comfort zone Try to pick
 * them from different topics CP is a sport, enjoy it. Don't make it pressure
 * cooker or job ****Use pen and paper************* check few examples analyze
 * them, some not given in sample also analyze then code Use pen and paper.
 * Solve on paper then code. If there is some reasoning e.g. sequence/paths, try
 * printing first 100 elements or 100 answers using brute and observe.
 * *********Read question with extreme caution. Mistake is happening here which
 * costs time, WA and easy problem not getting solved.********* Sometimes we
 * make question complex due to misunderstanding. Prefix sum and suffix sum is
 * highly usable concept, look for it. Think of cleanest approach. If too many
 * if else are coming then its indication of WA. Solve 1-2 more questions than
 * you solved during contest.
 */
public class Codeforces {

	static int max = (int) 1e7;

	public static void main(String args[]) throws IOException {
//		Scanner in = new Scanner(System.in);
		Reader in = new Reader();
		int t = in.nextInt();
		while (t-- > 0) {
			long a = in.nextLong(), b = in.nextLong(), c = in.nextLong(), n = in.nextLong();
			long sum = a+b+c+n;
			if (sum%3!=0) {
				System.out.println("NO");
				continue;
			}
			sum = sum/3;
			if (a>sum || b>sum || c>sum) {
				System.out.println("NO");
				continue;
			}
			System.out.println("YES");
		}
		in.close();
	}

	static class Pair {
		Integer x;
		Integer y;

		private Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public boolean equals(Object o) {
			if (o == null || !(o instanceof Pair))
				return false;
			Pair cor = (Pair) o;
			return x.equals(cor.x) && y.equals(cor.y);
		}

		@Override
		public int hashCode() {
			int result = 17;
			return result;
		}

		static class PairComparatorX implements Comparator<Pair> {

			@Override
			public int compare(Pair o1, Pair o2) {
				return o1.x.compareTo(o2.x);
			}

		}

		static class PairComparatorY implements Comparator<Pair> {

			@Override
			public int compare(Pair o1, Pair o2) {
				return o1.y.compareTo(o2.y);
			}

		}

	}

	private static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;
		StringTokenizer st;
		BufferedReader br;

//		public static void main(String args[]) throws IOException {
//			Reader in = new Reader();
//			int n = in.nextInt();
//			String s[] = new String[n];
//			for (int i=0;i<n;i++) s[i] = in.next();
//			for (int i=0;i<n;i++) System.out.println(s[i]);
//
//		}
		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}

	}

}


import java.util.Scanner;

public class CollectionCoin {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int t=scan.nextInt();
		while(t-->0) {
			int x=0;
			int[] a=new int[4];
			for(int i=0;i<4;i++) {
				a[i]=scan.nextInt();
				x+=a[i];
			}
			int y=Math.max(a[0], Math.max(a[1], a[2]));
			if(x%3==0 && x/3>=y)System.out.println("YES");
			else System.out.println("NO");
		}

	}

}


import java.util.Scanner;

public class CollectionCoin {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int t=scan.nextInt();
		while(t-->0) {
			int x=0;
			int[] a=new int[4];
			for(int i=0;i<4;i++) {
				a[i]=scan.nextInt();
				x+=a[i];
			}
			if(x%3==0)System.out.println("YES");
			else System.out.println("NO");
		}

	}

}


import java.util.Scanner;

public class CollectionCoin {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int t=scan.nextInt();
		int x=0;
		while(t-->0) {
			int[] a=new int[4];
			for(int i=0;i<4;i++) {
				a[i]=scan.nextInt();
				x+=a[i];
			}
			if(x%3==0)System.out.println("YES");
			else System.out.println("NO");
		}

	}

}


import java.util.Scanner;

public class CollectionCoin {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int t=scan.nextInt();
		while(t-->0) {
			int x=0;
			int[] a=new int[4];
			for(int i=0;i<4;i++) {
				a[i]=scan.nextInt();
				x+=a[i];
			}
			int y=Math.max(a[0], Math.max(a[1], a[2]));
			if(x%3==0 && x/3>y)System.out.println("YES");
			else System.out.println("NO");
		}

	}

}


import java.util.Scanner;

public class Collecting_coins
{
    static long max(long a, long b, long c)
    {

        if (a>=b && a>=c) return a;
        else if (b>=a && b>=c) return b;
        else return c;
    }

    static long  equal(long a,long b,long c,long n)
    {
        long max_no = max(a,b,c);

        long k;
        if (a<max_no)
        {
            k = max_no - a;

            if(n-k >=0)
            {
                a = a + k;
                n = n - k;
            }
        }
        if (b<max_no)
        {
            k = max_no - b;

            if(n-k >= 0)
            {
                b = b + k;
                n = n - k;
            }
        }
        if (c<max_no)
        {
            k = max_no - c;

            if(n-k >=0)
            {
                c = c + k;
                n = n - k;
            }
        }

        if (a == b && b == c)
        {
            if(n%3==0) return 1;
            else return -1;
        }
        else return -1;
    }
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-->0)
        {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            long n = in.nextLong();

            long res = equal(a,b,c,n);

            if (res==1) System.out.println("YES");
            else System.out.println("NO");

        }
    }
}


import java.util.Scanner;

public class Collecting_coins
{
    static int max(int a, int b, int c)
    {

        if (a>b && a>c) return a;
        else if (b>a && b>c) return b;
        else return c;
    }

    static int  equal(int a,int b,int c,int n)
    {
        int max_no = max(a,b,c);

        int k;
        if (a<max_no)
        {
            k = max_no - a;

            if(n-k >=0)
            {
                a = a + k;
                n = n - k;
            }
        }
        if (b<max_no)
        {
            k = max_no - b;

            if(n-k >= 0)
            {
                b = b + k;
                n = n - k;
            }
        }
        if (c<max_no)
        {
            k = max_no - c;

            if(n-k >=0)
            {
                c = c + k;
                n = n - k;
            }
        }

        if (a == b && b == c)
        {
            if(n%3==0) return 1;
            else return -1;
        }
        else return -1;
    }
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-->0)
        {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int n = in.nextInt();

            int res = equal(a,b,c,n);

            if (res==1) System.out.println("YES");
            else System.out.println("NO");

        }
    }
}