You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.

The single line contains 4 integers a, b, c, l (1 ≤ a, b, c ≤ 3·105, 0 ≤ l ≤ 3·105).

Print a single integer — the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.

NoteIn the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.

#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

typedef long long ll;

int main(int argc, char **argv) {
    int a[3],l;
    ll comb;
    cin >> a[0] >> a[1] >> a[2] >> l;
    comb = 1LL*(l+1)*(l+2)*(l+3)/6;

    ll untri = 0;
    for(int i = 0; i < 3; i++) {
        int aa = a[i];
        int bb = a[(i+1)%3];
        int cc = a[(i+2)%3];
        for(int j = 0; j <= l; j++) {
            if(aa + j < bb + cc) continue;
            int x = min(l-j, (aa+j-bb-cc));
            untri += 1LL*(x+1)*(x+2)/2;
        }
    }

    ll result = comb - untri;
    cout << result << endl;

    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair <int, int>
#define vi vector<int>

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define FORd(i, a, b) for (int i=a-1; i>=b; i--)
#define F0Rd(i, a) for (int i=a-1; i>=0; i--)
#define F0R(i, a) for (int i=0; i<a; i++)

#define f first
#define s second
// #define b begin
#define e end
#define lb lower_bound
#define ub upper_bound
#define sz size

const int MOD = 1000000007;
double PI = 4*atan(1);

ll a,b,c,l,ans = 0;

void solve() {
	F0R(i,l+1)
		if (l-i >= max((ll)0,(a+b-c+i)))
			ans -= (i+1)*(l-i-max((ll)0,(a+b-c+i))+1);
}

int main() {
	cin >> a >> b >> c >> l;
	ans = (l+3)*(l+2)*(l+1)/6;
	solve();
	swap(a,c);
	solve();
	swap(b,c);
	solve();
	cout << ans;
	// z >= a+x+b+y-c
	// x+y+z<= l
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main () {
    int x [3], l;
    scanf ("%d%d%d%d", x, x + 1, x + 2, &l);
    long long ans = 1LL *  (l  + 3) * (l + 2) * (l + 1) / 6;
    for (int i = 0; i < 3; i ++)
        for (int lx = 0; lx <= l; lx ++) {
            int xx = min (l - lx, x [i] + lx - x [(i + 1) % 3] - x [(i + 2) % 3]);
            if (xx >= 0)    ans -= 1LL * (2 + xx) * (1 + xx) / 2;
        }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1000010;
const int mod = 1e9 + 7;

int f(int x) {
  if(x < 0) return 0;
  return x * (x - 1) / 2;
}

int calc(int x, int y, int lx, int ly, int sum, int chk) {
  if(x + y + sum < chk) return 0;
  if(x > lx || y > ly) return 0;

  vector < int > vec;
  vec.emplace_back(lx - x + 1);
  vec.emplace_back(ly - y + 1);
  vec.emplace_back(sum - (chk - x - y));

  int ret = 0;

  for(int mask = 0; mask < 8; ++mask) {
    int v = sum + 2;
    for(int i = 0; i < 3; ++i) {
      if(mask & (1 << i)) v -= vec[i];
    }
    if(__builtin_popcount(mask) % 2 == 0) ret += f(v);
    else ret -= f(v);
  }

  return ret;
}

main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ans = 0;
  for(int i = 0; i <= d; ++i) {
    ans += calc(b, c, a + i - 1, a + i - 1, d - i, a + i);
    ans += calc(a, c, b + i, b + i - 1, d - i, b + i);
    ans += calc(a, b, c + i, c + i, d - i, c + i);
  }

  cout << ans << endl;

  return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int T,t;
ll solve(ll a,ll b,ll c,ll m)
{
    ll ret=min(a-b-c,m);
    if(ret<0)
      return 0;
    else
      return (ret+2)*(ret+1)/2;
}
int main()
{
    int i,j,k;
    ll a,b,c,n,ans;
    scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&n);
    ans=(n+3)*(n+2)*(n+1)/6;
    for(i=0;i<=n;i++)
    {
        ans-=solve(a+i,b,c,n-i);
        ans-=solve(b+i,a,c,n-i);
        ans-=solve(c+i,a,b,n-i);
    }
    printf("%I64d\n",ans);
}

#include <bits/stdc++.h>
#define int long long

using namespace std;

const int mod = 1e9 + 7;

int C(int n, int k) {
  int ret = 1;
  for(int i = n; i > n - k; --i) {
    ret *= i;
  }
  for(int i = 1; i <= k; ++i) {
    ret /= i;
  }
  return ret;
}

main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int sum = 0;

  int d;
  vector < int > vec(3);
  for(auto &x : vec) cin >> x, sum += x;
  cin >> d;

  int all = C(d + 3, 3);

  for(int i = 0; i < 3; ++i) {
    for(int v = 0; v <= d; ++v) {
      int lim = vec[i] + v;
      if(sum - vec[i] > lim) continue;
      int rem = min(d - v, lim - (sum - vec[i]));
      all -= C(rem + 2, 2);
    }
  }

  cout << all;

  return 0;
}

#include<iostream>
#include<stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;
#define LL long long int

LL calc(LL a, LL b, LL c, LL l){
    LL total = a + b + c + l;
    LL sum = 0;
    for (LL i = a; i <= a+l; ++i) {
        if (i >= b+c) {
            LL x = min(i , total -i) - b - c +1;
            sum += x* (x+1) /2;
        }
    }
    return sum;
}

int main(){
    LL a,b,c,l;
    LL ans = 0;
    cin >> a >> b >> c >>l;
    ans = 0;
    for(LL i=0;i<=l;i++){
        ans += (i+1)*(i+2)/2;
    }
    ans -= calc(a,b,c,l);
    ans -= calc(b,a,c,l);
    ans -= calc(c,a,b,l);
    cout << ans << endl;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<queue>
#include<stack>
#include<map>

using namespace std;

long long int minn(long long int xx,long long int yy){
    if(xx<yy){
        return xx;
    }
    return yy;
}

long long int IEP(long long int a,long long int b,long long int c,long long int l){
    long long int s = 0;
    long long int maxn = a + b + c + l;
    for(long long int i=a;i<=a+l;i++){
        if(b+c<=i){
            long long int xx = min(i,maxn-i)-b-c;
            s += (xx+1)*(xx+2)/2;
        }
    }
    return s;
}

int main(){
    __int64 a,b,c,l;
    __int64 ans = 0;
    while(scanf("%lld%lld%lld%lld",&a,&b,&c,&l)!=EOF){
        ans = 0;
        for(__int64 i=0;i<=l;i++){
            ans += (i+1)*(i+2)/2;
        }
        ans -= IEP(a,b,c,l);
        ans -= IEP(b,a,c,l);
        ans -= IEP(c,a,b,l);
        printf("%lld\n",ans);
    }
    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<map>
#include<queue>
#include<iterator>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define CLR(a) memset(a,0,sizeof(a))
#define ll long long
#include<ctime>
#include<cmath>
#include<vector>
#include<iostream>

int a, b, c, n, low, reallow, high, realhigh;
int lowbound, upbound, k, x, y, z, w;
ll ans;

void solve3(int a, int b, int c, int n)
{
	FOE(i, 1, 600000)
	{
		if (a > i || b > i || c > i) continue;
		if (i * 3 - a - b - c > n) break;
		ans++;
	}
}

void solve2(int a, int b, int c, int n)
{
	FOE(i, 1, 600000)
	{
		if (a > i || b > i || c >= i) continue;
		if (i + i - a - b > n) break;
		ans += (ll)(min(n - (i + i - a - b) + 1, i - c));
	}
}

ll calc(int pos, ll k)
{
	ll a = (ll)(pos - low + 1);
	ll b = (ll)(lowbound - low + 1);
	ll c = (ll)(upbound - lowbound - 1);
	ll d = (ll)(high - pos);

	if (pos < low) return 0ll;
	else if (pos <= lowbound) return a * (a + 1) / 2ll;
	else if (pos <= upbound) return b * (b + 1) / 2ll + (ll)(pos - lowbound) * k;
	else return b * (b + 1) + c * k - (d * (d + 1) / 2ll);
}

void solve1(int a, int b, int c, int n)
{
//	printf("top %d %d %d\n", a, b, c);

	FOE(i, 1, 600000)
	{
		if (a > i || b >= i || c >= i) continue;
		if (i - a > n) break;

		k = min(i - c, i - b);

		high = i + i - 2;
		realhigh = b + c + (n - (i - a));
		low = b + c;
		reallow = i + 1;

		realhigh = min(realhigh, high);
		reallow = max(reallow, low) - 1;

		lowbound = low + k - 1;
		upbound = high - k + 1;

		if (reallow > realhigh) continue;

	//	printf("hanayo %d %d %d %d %d %d %d\n\n", low, high, reallow, realhigh, lowbound, upbound, k);

		ans -= calc(reallow, k);
		ans += calc(realhigh, k);

	//	printf("nico %d %d %d %d %d\n\n", i, b, c, n - (i - a), ans);
	}
}

int main ()
{
	scanf("%d %d %d %d", &a, &b, &c, &n);

	solve3(a, b, c, n);
//	printf("%I64d\n", ans);

	solve2(a, b, c, n);
	solve2(a, c, b, n);
	solve2(b, c, a, n);
//	printf("%I64d\n", ans);

	solve1(a, b, c, n);
	solve1(b, a, c, n);
	solve1(c, a, b, n);

	printf("%I64d\n", ans);

	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define pb   push_back
#define mp   make_pair
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie() , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX
#define INF 0x3f3f3f3f

int ans , lim;
int N(int a , int b , int c){
	int cnt = 0;
	REP(i , 0 , lim + 1){
		int now = a + i , have = lim - i;
		int tmp = min(have , now - (b + c));
		if(tmp < 0) continue;
		cnt += (tmp + 1) * (tmp + 2) / 2;
	}
	return cnt;
}
int32_t main(){
	int a , b , c;
	cin >> a >> b >> c >> lim;
	REP(i , 0 , lim + 1) ans += (i + 2) * (i + 1) / 2;
	ans -= N(a , b , c);
	ans -= N(b , a , c);
	ans -= N(c , a , b);
	cout << ans << endl;
    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cctype>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <fstream>
#define debug "output for debug\n"
#define pi (acos(-1.0))
#define eps (1e-8)
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 100005;
ll check(ll a)
{
    return (a+1)*(a+2)/2;
}
int main()
{
    ll sum;
    ll a,b,c,l;
    while(scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&l)!=EOF)
    {
        sum=(l+1)*(l+2)*(l+3)/6;
        for(ll i=0;i<=l;i++)
           {
        if (a + i >= b + c) sum=sum-check(min(l - i, a + i - b - c));
        if (b + i >= a + c)sum=sum-check(min(l - i, b + i - a - c));
        if (c + i >= a + b)sum=sum-check(min(l - i, c + i - a - b));
           }
        printf("%I64d\n",sum);
    }
    return 0;

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
//#define PB emplace_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'

const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

//
//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)

int main()
{
	optimize();
	ll a, b, c, l;
	cin >> a >> b >> c >> l;
	ll ans = ((l + 3)*(l + 1)*(l + 2))/6LL;
	//dbg(ans);
	for( ll i = a; i <= a+l; ++i ) {
		if( i <= b || i <= c ) continue;
		if( i < b+c ) continue;
		ll rem = min( l-i+a, i-b-c );
		ans -= ((rem + 2)*(rem + 1))/2LL;
	}
	for( ll i = b; i <= b+l; ++i ) {
		if( i <= a || i <= c ) continue;
		if( i < a+c ) continue;
		ll rem = min( l-i+b, i-a-c );
		ans -= ((rem + 2)*(rem + 1))/2LL;
	}
	for( ll i = c; i <= c+l; ++i ) {
		if( i <= a || i <= b ) continue;
		if( i < a+b ) continue;
		ll rem = min( l-i+c, i-a-b );
		ans -= ((rem + 2)*(rem + 1))/2LL;
	}
	cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define M 300005
#define ll long long
int l;
ll solve(int a,int s){
	ll res=0;
	for(int i=l;~i;i--){
		if(s>a+i)break;
		int t=min(l-i,a+i-s);
		res+=1ll*(t+2)*(t+1)/2;
	}
	return res;
}
int main(){
	int a,b,c;
	scanf("%d%d%d%d",&a,&b,&c,&l);
	ll ans=1ll*(l+3)*(l+2)*(l+1)/6;
	ans-=solve(a,b+c)+solve(b,a+c)+solve(c,a+b);
	cout<<ans;
	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
	ll a[3], l;
	cin >> a[0] >> a[1] >> a[2] >> l;

	ll total = (l + 1) * (l + 2) * (l + 3) / 6;
	ll perimeter = a[0] + a[1] + a[2];
	for (ll i = 0; i < 3; i++)
	{
		ll sides_length = perimeter - a[i];
		for (ll extension = max(sides_length - a[i], 0ll); extension <= l; extension++)
		{
			ll diff = min(l - extension, a[i] + extension - sides_length);
			total -= (diff + 1) * (diff + 2) / 2;
		}
	}

	cout << total;
}

//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

LL a, b, c, l, ans;

int main()
{
    cin>>a>>b>>c>>l;
    For(i,0,l+1) ans+=(l-i+1)*(l-i+2)/2;
    For(i,max(0LL,b+c-a),l+1)
    {
        LL q=min(l-i,a+i-b-c)+1;
        ans-=q*(q+1)/2;
    }
    swap(a,b);
    For(i,max(0LL,b+c-a),l+1)
    {
        LL q=min(l-i,a+i-b-c)+1;
        ans-=q*(q+1)/2;
    }
    swap(a,c);
    For(i,max(0LL,b+c-a),l+1)
    {
        LL q=min(l-i,a+i-b-c)+1;
        ans-=q*(q+1)/2;
    }
    cout<<ans;
    return 0;
}

#pragma comment(linker,"/stack:67108864")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <climits>
#include <cfloat>
#include <functional>
#include <ctime>
#include <numeric>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <utility>
#include <bitset>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <typeinfo>
#include <cassert>
#include <ctime>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forn1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = int(n); i > 0; --i)
#define foran(i, a, n) for(int i = int(a); i <= int(n); ++i)

#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define all(v) (v).begin(),(v).end()

typedef long double ld;
typedef long long ll;

const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
const ll INF = 1000 * 1000 * 1000 + 9;
const int NMAX = 1000*1000 + 3;

int a, b, c, l;

inline bool read()
{
    if (!(cin >>a >>b >>c >>l))
        return false;
    return true;
}

ll calc(int a, int b, int len)
{
    ll ans = 0;
    if (a > b) swap(a, b);
    if (len <= a)
        ans = 1LL * (len + 1) * (len + 2) / 2;
    if (a < len && len < b)
        ans = 1LL * (len - a + 1 + len + 1) * (a + 1) / 2;
    if (b <= len && len < a + b)
    {
        int a_f = len - b;
        ans = 1LL * (a_f + 1) * (b + 1);
        ans += 1LL *(a - a_f) * (len - a + 1 + b) / 2;
    }
    if (len >= a + b)
        ans = 1LL * (a + 1) * (b + 1);
    return ans;
}

ll a_bc(int a, int b, int c, int l)
{
    //calculate number of triangles with biggest side a
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        if (b + c + l - i <= newa) continue;
        int addmin = max(0, newa - b - c + 1);
        int addmax = l - i;
        int mlb = newa - 1 - b;
        int mlc = newa - 1 - c;
        if (mlb < 0 || mlc < 0) continue;
        if (mlb + mlc < addmin) continue;
        ans += calc(mlb, mlc, addmax) - calc(mlb, mlc, addmin - 1);
        //cerr <<mlb <<' ' <<mlc <<' ' <<addmax <<endl;//calc(mlb, mlc, addmax) <<endl;
    }
    return ans;

}

ll ab_c(int a, int b, int c, int l)
{
    //calculate number of triangles with biggest equal sides a and b
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        int newb = newa;

        if (newb < b) continue;
        int addmin = (newa - a) + (newb - b) ;
        if (addmin > l) continue;
        if (newa <= c) continue;
        ans += (ll)min(l - addmin + 1, newa - c);
    }
    return ans;
}

ll eq_triangles(int a, int b, int c, int l)
{
    //calculate equilateral triangles
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        int newb = newa;
        int newc = newa;

        if (newb < b) continue;
        if (newc < c) continue;
        int addmin = (newa - a) + (newb - b) + (newc - c) ;
        if (addmin > l) continue;
        ans ++;
    }
    return ans;
}

inline void solve()
{
    ll ans = 0;
    ans += a_bc(a, b, c, l);
    ans += a_bc(b, a, c, l);
    ans += a_bc(c, a, b, l);
    ans += ab_c(a, b, c, l);
    ans += ab_c(a, c, b, l);
    ans += ab_c(b, c, a, l);
    ans += eq_triangles(a, b, c, l);
    cout <<ans <<endl;
}

int main()
{
    ifstream ifile("input.txt");
    if (ifile) {
        freopen("input.txt", "rt", stdin);
    }
#ifdef ONLINE_JUDGE
    if (ifile) {
        freopen("output.txt","wt",stdout);
    }
#endif
    while(read())
        solve();
    return 0;
}

#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;
const int limit = 1048576;

using namespace std;

#define LOCAL
#ifndef LOCAL
#define cerr if(0)cout
#define endl "\n"
#endif

ll suma(ll a, ll b)
{
	return b*(b+1)/2ll - a*(a-1)/2ll;
}

int main()
{
   // ios_base::sync_with_stdio(0);
   // cin.tie(0);

	vector < ll > V(3);
	for(auto& el : V)
		cin>>el;
	sort(all(V));
	ll l;
	cin>>l;
	ll wyn = (l+3ll)*(l+2ll)*(l+1ll)/6ll;
//	cout << wyn << endl;
	for(ll i = max(0ll, V[1] + V[2] - V[0]); i<=l; i++)
	{
		ll max_inny = min(l-i, i + V[0] - V[1] - V[2]);
		wyn -= suma(0ll, max_inny+1);
	}
	for(ll i = V[0] - V[1] + V[2]; i<=l; i++)
	{
		ll max_inny = min(l-i, i + V[1] - V[0] - V[2]);
		wyn -= suma(0ll, max_inny+1);
	}
	for(ll i = max(0ll, V[0] + V[1] - V[2]); i<=l; i++)
	{
		ll max_inny = min(l-i, i + V[2] - V[1] - V[0]);
	//cout << "A" << max_inny << " " << i << endl;
		wyn -= suma(0, max_inny+1);
	}
	cout << wyn << endl;
	return 0;
}

// C1.cpp: ���������� ����� ����� ��� ����������� ����������.
//

#include<iostream>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<map>
#include<iterator>
#include<queue>
#include<vector>
#include<ctime>
#include<time.h>
#include<cstdio>
#include<set>
#include<sstream>
#include<string>
#include<iomanip>
#include<tuple>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long LL;

LL cnt(int a, int b, int c, int s)
{
	if (s + a < b + c)
	{
		return 0;
	}
	LL cur = min(s, (s + a - b - c) / 2);
	return (cur + 1) * (cur + 2) / 2;
}

int main()
{
	LL m[3], l;
	LL ans = 0;
	for (int i = 0; i < 3; i++)
		cin >> m[i];
	cin >> l;
	for (int i = 0; i <= l; i++)
	{
		ans += (LL)((l - i + 1) * (l - i + 2) / 2);
	}
	for (int i = 0; i < 3; i++)
	{
		for (int s = 0; s <= l; s++)
		{
			ans -= cnt(m[i], m[(i + 1) % 3], m[(i + 2) % 3], s);
		}
	}
	cout << ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
//int a[3];
long long find(long long n){
	if(n<2) return 0;
	else return (n*(n-1))/2;
}
int main(){
	long long a,b,c,l;
	cin>>a>>b>>c>>l;
	long long ans=((l+1)*(l+2)*(l+3))/6;
	//cout<<ans<<endl;
	for(int i=0;i<=l;i++) {
		ans=ans-find(min(a-b-c+i,l-i)+2)-find(min(b-c-a+i,l-i)+2)-find(min(c-a-b+i,l-i)+2);
	}
	//if(a[0]+a[1]>a[2]&&a[0]-a[1]<a[2]) ans+=1;
	cout<<ans<<endl;
}

#include <bits/stdc++.h>
using  namespace std;
int main()
{
	long long a, b, c, l;
	cin >> a >> b >> c >> l;
	long long d[3];
	d[0] = a; d[1] = b; d[2] = c;
	long long jam = a + b + c;
	long long javab = 0;
	javab = (l + 1) * (l + 2) * (l + 3) / 6;
	for (int i = 0; i <= l; i++)
		for (int j = 0; j < 3; j++)
		{
			long long x = 2 * d[j] - jam + i;
			long long y = l - i;
			long long z = min(x, y);
			if (z >= 0)
				javab -=(z + 1) * (z + 2) / 2;

		}
	cout << javab << endl;
}

/*
 * socode.online
 *
 * Author: qiaotianchang
 * E-mail: chy668755@126.com
 * Time  : 2019-12-06 18:59:49
 */
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll a,b,c,l;
ll ans;
ll exc(ll x,ll y,ll z,ll len)
{
	ll sum=0;
	for(ll i=max((ll)0,y+z-x);i<=len;i++)
	{
		ll tmp=min(len-i,x+i-y-z)+2;
		sum+=(tmp-1)*tmp/2;
	}
	return sum;
}

int main()
{
	scanf("%lld %lld %lld %lld",&a,&b,&c,&l);
	ans=(l+3)*(l+2)*(l+1)/6;
	ans-=exc(a,b,c,l);
	ans-=exc(b,a,c,l);
	ans-=exc(c,a,b,l);
	printf("%lld\n",ans);
	return 0;
}

//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("1.in","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ull ba=233;
const db eps=1e-5;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=40000+10,maxn=2000000+10,inf=0x3f3f3f3f;

int main()
{
    int a,b,c,l;scanf("%d%d%d%d",&a,&b,&c,&l);
    ll ans=0;
    for(int i=0;i<=l;i++)ans+=1ll*(i+1)*(i+2)/2;
    auto f = [&](int a,int b,int c)
    {
        ll ans=0;
        for(int i=max(b+c-a,0);i<=l;i++)
        {
            int te=min(i-b-c+a,l-i);
            ans+=1ll*(te+1)*(te+2)/2;
        }
        return ans;
    };
    ans-=f(a,b,c);
    ans-=f(b,a,c);
    ans-=f(c,a,b);
    printf("%lld\n",ans);
    return 0;
}
/********************

********************/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <stack>
#include <bitset>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#define FOP freopen("data.txt","r",stdin)
#define FOP2 freopen("data1.txt","w",stdout)
#define inf_LL 4223372036854775807
#define inf 0x3f3f3f3f
#define maxn 1000010
#define mod 1000000007
#define PI acos(-1.0)
#define LL long long
using namespace std;

LL a, b, c, l;

LL solve(LL la, LL a, LL b, LL c)
{
    if(la+a < b+c) return 0;
    LL x = min(la+a-b-c, l-la);
    return (x+1)*(x+2)/2;
}

int main()
{
    while(~scanf("%lld%lld%lld%lld", &a, &b, &c, &l))
    {
        LL ans = (l+1)*(l+2)/2*(l+3)/3;
        for(int li = 0; li <= l; li++)
        {
            ans -= solve(li, a, b, c);
            ans -= solve(li, b, c, a);
            ans -= solve(li, c, a, b);
        }
        printf("%lld\n", ans);
    }
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main(){
	long long a,b,c,l,diff,sub,mn;
	cin >> a >> b >> c >> l;
	long long ans = (l+3)*(l+1)*(l+2);
	ans/=6;
//	cout << ans << endl;
	for(long long i=max(a+b,c);i<=c+l;i++){
		diff = i-(a+b);
		if(diff<0)
			continue;
		mn=min(diff,l-i+c);
//		cout << a+b << ' ' << c+i << ' ' << mn << endl;
		sub = (mn+2)*(mn+1);
		sub/=2;
		ans-=sub;
	}
	for(long long i=max(c+b,a);i<=a+l;i++){
		diff = i-(c+b);
		if(diff<0)
			continue;
		mn=min(diff,l-i+a);
//		cout << a+b << ' ' << c+i << ' ' << mn << endl;
		sub = (mn+2)*(mn+1);
		sub/=2;
		ans-=sub;
	}
	for(long long i=max(a+c,b);i<=b+l;i++){
		diff = i-(a+c);
		if(diff<0)
			continue;
		mn=min(diff,l-i+b);
//		cout << a+b << ' ' << c+i << ' ' << mn << endl;
		sub = (mn+2)*(mn+1);
		sub/=2;
		ans-=sub;
	}
	cout << ans << endl;
	return 0;
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>

using namespace std;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int a, b, c, l;

LL halp(int mx, int b, int c, int len) {
    if (len < 0) return 0;
    if (b > mx || c > mx) return 0;
    b = mx - b;
    c = mx - c;
    if (b > len) {
        ++len, ++c;
        LL ret = (LL)len * (len + 1) / 2;
        if (c < len) {
            c = len - c;
            ret -= (LL)c * (c + 1) / 2;
        }
        return ret;
    }
    if (c > len) {
        ++len, ++b;
        LL ret = (LL)len * (len + 1) / 2;
        if (b < len) {
            b = len - b;
            ret -= (LL)b * (b + 1) / 2;
        }
        return ret;
    }
    LL ret = LL(b + 1) * (c + 1);
    if (b + c > len) {
        int sz = b + c - len;
        ret -= (LL)sz * (sz + 1) / 2;
    }
    return ret;
}

LL solve(int a, int b, int c) {
    LL ans = 0;
    for (int i = 0; i <= l; ++i) {
        if (a + i < b + c + l - i) {
            ans += halp(a + i - 1, b, c, l - i);
            ans -= halp(a + i - 1, b, c, a + i - b - c);
        }
    }
    return ans;
}

LL solve2(int a, int b, int c) {
    LL ans = 0;
    for (int x = max(a, b); 2 * x - a - b <= l; ++x) {
        int mx = min(c + l - (2 * x - a - b), x - 1);
        int mn = c;
        if (mx >= mn) {
            ans += mx - mn + 1;
        }
    }
    return ans;
}

LL solve3(int a, int b, int c) {
    LL ans = 0;
    for (int x = max(max(a, b), c); 3 * x - a - b - c <= l; ++x) {
        ++ans;
    }
    return ans;
}

int main() {
    //freopen("input.txt", "r", stdin);
    scanf("%d%d%d%d", &a, &b, &c, &l);
    LL ans = 0;
    ans += solve(a, b, c);
    ans += solve(b, a, c);
    ans += solve(c, a, b);
    ans += solve2(a, b, c);
    ans += solve2(a, c, b);
    ans += solve2(b, c, a);
    ans += solve3(a, b, c);
    cout << ans << endl;
    return 0;
}

// @Author :- Gaurav Bharti
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define vii vector<int>
#define vbl vector<bool>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int>
#define mapll map<ll,ll>
#define lcm(a,b) a*b/(__gcd(a,b))
#define all(a) a.begin(),a.end()
#define test int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

ll binpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b&1) res = res * a;
		a = a* a;
		b = b >> 1;
	}
	return res;
}

ll count(ll a, ll b, ll c, ll j) {
	if(j + a < b + c) {
		return 0;
	}
	ll cur = min(j, (j + a - b - c)/2);
	return (cur + 1) * (cur + 2) /2 ;
}

int main() {
   	ItsFUN;

   	ll a[3];
   	ll l ;cin >> a[0] >> a[1] >> a[2] >> l;

   	ll ans = 0;

   	for(ll i = 0; i <=l ; i += 1) {
   		ans += (l - i + 1) * (l - i + 2) / 2;
   	}

   	for(ll i = 0; i < 3; ++i) {
   		for(ll j = 0; j <=l; ++j) {
   			ans -= count(a[i],a[(i+1)%3], a[ (i+2)%3 ], j);
   		}
   	}

   	cout << ans << "\n";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fun(ll a,ll b,ll c,ll l)
{
	ll ans=0;
	for (ll k=max(b+c-a,0LL);k<=l;k++)
	{
		ll x=min(l-k,a+k-b-c);
		ans+=(x+1)*(x+2)/2;
	}
	return ans;
}
int main()
{
	ll a,b,c,l;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&l);
	ll ans=0;
	for (ll k=0;k<=l;k++) ans+=(k+1)*(k+2)/2;
	ans-=fun(a,b,c,l);
	ans-=fun(b,a,c,l);
	ans-=fun(c,a,b,l);
	printf("%lld\n",ans);
	return 0;
}

#include <cstdio>

#define REP(i, n) for(int _n = n, i = 0; i < _n; i++)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define RFOR(i, b, a) for (int i = (b), _b = (a); i >= _b; i--)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Abs(x) ((x) > 0 ? (x) :(-(x)))
#define L(fmt, ...) do {if(true) printf(fmt"\n", ##__VA_ARGS__);} while(false)

int main(){
	int a, b, c;
	int la, lb, lc;
	long long x, l;
	scanf("%d%d%d%lld", &a, &b, &c, &l);
	long long cnt = 0;
	REP(i, l + 1) {
		x = Min(a - b -c + i, l - i);
		if (x >= 0 )
			cnt += (x + 1) * (x + 2) / 2;
	}
	REP(i, l + 1) {
		x = Min(b - a - c + i, l - i);
		if (x >= 0)
			cnt += (x + 1) * (x + 2) / 2;
	}
	REP(i, l + 1) {
		x = Min(c - a - b + i, l - i);
		if (x >= 0)
			cnt += (x + 1) * (x + 2) / 2;
	}
	long long t = (l + 3) * (l + 2) * (l + 1) / 6;
	long long res = t - cnt;
	printf("%lld\n", res);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long a,b,c,l,ans;
void did(long long lastlen){
	ans=ans-(lastlen+2)*(lastlen+1)/2;
}
int main(){
	cin>>a>>b>>c>>l;
	ans=(l+3)*(l+2)*(l+1)/6;
	for(long long i=0;i<=l;i++){
		if(a+i>=b+c)did(min(i,i-(a+b+c+i+1)/2+a));
		if(b+i>=a+c)did(min(i,i-(a+b+c+i+1)/2+b));
		if(c+i>=a+b)did(min(i,i-(a+b+c+i+1)/2+c));
	}
	cout<<ans;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen( "input", "r", stdin );
    //freopen( "output","w",stdout );

    int val, a, b, c, l;
    long long ans = 1;

    cin >> a >> b >> c >> l;

    ans = 1LL * (l + 3) * (l + 2) * (l + 1) / 6;

    for (int i = 0; i <= l; i++) {
        val = min( a - b - c + i, l - i );

        if (val >= 0)
            ans -= (1LL * (val + 2) * (val + 1) / 2);
    }

    for (int i = 0; i <= l; i++) {
        val = min( b - a - c + i, l - i );
        if (val >= 0)
            ans -= (1LL * (val + 2) * (val + 1) / 2);
    }

    for (int i = 0; i <=l; i++) {
        val = min( c - a - b + i, l - i );
        if (val >= 0)
            ans -= (1LL * (val + 2) * (val + 1) / 2 );
    }

    cout << ans;

    return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
long long f(long long x)
{
    return (x+1)*(x+2)/2;
}
int main()
{
    long long a,b,c,l;
    while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&l))
    {
        long long ans=0;
        ans=(l+1)*(l+2)*(l+3)/6;
        for(long long i=0;i<=l;i++)
        {
            if(a+i>=b+c)
                ans=ans-f(min(l-i,a+i-b-c));
            if(b+i>=a+c)
                ans=ans-f(min(l-i,b+i-a-c));
            if(c+i>=a+b)
                ans=ans-f(min(l-i,c+i-a-b));
        }
        printf("%lld\n",ans);
    }
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846

typedef tree<pii,null_type,less<pii>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

int a, b, c, l;

void solve()
{
	cin >> a >> b >> c >> l;

	int tot = 0;
	int no = 0;

	int sum = a + b + c + 1;

	rep(i,1,l+1)
	{
		int ways = 0;
		tot += (i+2)*(i+1)/2;

		int x = (sum + i - 2*a)/2;

		if (x < 0) x = 0;

		if (x <= i)
			ways = (i - x + 1)*(i - x + 2)/2;

		x = (sum + i - 2*b)/2;

		if (x < 0) x = 0;

		if (x <= i)
			ways += (i - x + 1)*(i - x + 2)/2;

		x = (sum + i - 2*c)/2;

		if (x < 0) x = 0;

		if (x <= i)
			ways += (i - x + 1)*(i - x + 2)/2;
		no += ways;

	}

	if (a >= b + c || b >= a + c || c >= a + b) no ++;
	tot ++;

	cout << tot - no << "\n";

}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);

 	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif

	int t = 1;
	//cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
			cout << "\n";
		#endif

	}

	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
    #include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

/*
    we need to find ways to make invalid traingles
    and subtract it with total;

    for i in [0, l]:
        ways to distribute = (i + 3 - 1) C (3 - 1)
        semi perimeter = (a + b + c) / 2;

        invalid are those who doesnot obey the heron's formula
        (semi perimeter is <= either of sides)
*/

ll a, b, c, l;

void solve()
{
    ll ans = 0;
    for(ll i = 0; i <= l; i++)
    {
        ll perimeter = (a + b + c + i);
        ll half = (perimeter - 1) >> 1; // ceil

        // doesnot obey herons formula(we cannot make a valid traingle)
        if(a > half || b > half || c > half) continue;

        ll total = (i + 1) * (i + 2) / 2;

        if(a + i > half)
        {
            ll extra = (a + i - half - 1);
            total -= ((extra + 1) * (extra + 2) / 2);
        }
        if(b + i > half)
        {
            ll extra = (b + i - half - 1);
            total -= ((extra + 1) * (extra + 2) / 2);
        }
        if(c + i > half)
        {
            ll extra = (c + i - half - 1);
            total -= ((extra + 1) * (extra + 2) / 2);
        }
        ans += total;
    }
    cout << ans << endl;
}

int main()
{
    fast();
    cin >> a >> b >> c >> l;
    solve();
}

#include <bits/stdc++.h>
#define ft first
#define sd second
#define maxn 600005
#define mod
#define PI 3.14159265
#define MP make_pair
#define PB push_back
#define heap priority_queue
#define Bjerg ""
using namespace std;
int a,b,c,l;
long long C[4][maxn];
void init()
{
    for(int i=0;i<=6e5+3;++i) C[0][i]=1;
    for(int i=1;i<=3;++i)
    {
        for(int j=1;j<=6e5+3;++j)
        {
            C[i][j]=(C[i][j-1]+C[i-1][j-1]);
        }
    }
}
void read()
{
    cin >> a >> b >> c >> l;
}
void solve()
{
    long long res=C[3][l+3];
    for(int i=0;i<=l;++i)
    {
        {
            int x = (a+i);
            int y = (b+c);
            if(x>=y)
            {
                int z = min(x-y,l-i);
                res-=C[2][z+2];
            }
        }
        {
            int x = (b+i);
            int y = (a+c);
            if(x>=y)
            {
                int z = min(x-y,l-i);
                res-=C[2][z+2];
            }
        }
        {
            int x = (c+i);
            int y = (b+a);
            if(x>=y)
            {
                int z = min(x-y,l-i);
                res-=C[2][z+2];
            }
        }
    }
    cout << res;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Bjerg".inp","r",stdin);
    init();
    read();
    solve();
    return 0;
}

// C1.cpp: ���������� ����� ����� ��� ����������� ����������.
//

#include<iostream>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<map>
#include<iterator>
#include<queue>
#include<vector>
#include<ctime>
#include<time.h>
#include<cstdio>
#include<set>
#include<sstream>
#include<string>
#include<iomanip>
#include<tuple>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long LL;

LL cnt(int a, int b, int c, int s)
{
	if (s + a < b + c)
	{
		return 0;
	}
	LL cur = min(s, (s + a - b - c) / 2);
	return (cur + 1) * (cur + 2) / 2;
}

int main()
{
	LL m[3], l;
	LL ans = 0;
	for (int i = 0; i < 3; i++)
		cin >> m[i];
	cin >> l;
	for (int i = 0; i <= l; i++)
	{
		ans += (LL)((l - i + 1) * (l - i + 2) / 2);
	}
	for (int i = 0; i < 3; i++)
	{
		for (int s = 0; s <= l; s++)
		{
			ans -= cnt(m[i], m[(i + 1) % 3], m[(i + 2) % 3], s);
		}
	}
	cout << ans;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 0X6FFFFFFF;
const int MS = 1005;

ll work(int a,int b,int c,int l) {
    ll ans=0;
    for(int i=max(b+c-a,0);i<=l;i++) {
        ll x=min(l-i,a+i-b-c);
        ans+=(1+x)*(2+x)/2;
    }
    return ans;
}
int main()
{
    int a,b,c,l;
    cin>>a>>b>>c>>l;
    ll ans=0;
    for(int i=0;i<=l;i++)
        ans+=ll(1+i)*(2+i)/2;
    ans-=work(a,b,c,l);
    ans-=work(b,a,c,l);
    ans-=work(c,a,b,l);
    cout<<ans;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll A,B,C,L;
ll ret;
ll dp[303030];

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>A>>B>>C>>L;

	dp[0]=1;
	for(i=1;i<=300000;i++) dp[i]=dp[i-1]+i/2+1;

	for(i=0;i<=L;i++) {
		ll a=A+i;
		ll left = L-i;
		ret += (left+1)*(left+2)/2;
	}
	FOR(j,3) {
		for(i=0;i<=L;i++) {
			ll a=A+i;
			ll left = L-i;
			// B+b+C+c<=a
			ll x=min(left,a-B-C);
			if(x>=0) ret -= (x+1)*(x+2)/2;
		}
		if(j==0) swap(A,B);
		if(j==1) swap(A,C);
	}
	cout<<ret<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

#include<iostream>
#include<stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;
#define LL long long int

LL calc(LL a, LL b, LL c, LL l){
    LL total = a + b + c + l;
    LL sum = 0;
    for (LL i = a; i <= a+l; ++i) {
        if (i >= b+c) {
            LL x = min(i , total -i) - b - c +1;
            sum += x* (x+1) /2;
        }
    }
    return sum;
}

int main(){
    LL a,b,c,l;
    LL ans = 0;
    cin >> a >> b >> c >>l;
    ans = 0;
    for(LL i=0;i<=l;i++){
        ans += (i+1)*(i+2)/2;
    }
    ans -= calc(a,b,c,l);
    ans -= calc(b,a,c,l);
    ans -= calc(c,a,b,l);
    cout << ans << endl;
    return 0;
}

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

#define ll          long long
#define ld          long double
#define pb          push_back
#define nl          '\n'
#define X           first
#define Y           second
#define nimble      ios::sync_with_stdio(0);cin.tie(0);
#define all(v)      (v).begin(),(v).end()
#define _sz(x)      (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,b,a) for(int i=b;i>=a;i--)
#define preci(x)    fixed<<setprecision(x)
#define tc          int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble;
    ll a,b,c,l,x;
    cin>>a>>b>>c>>l;
    ll res=(l+3)*(l+2)*(l+1)/6;//stars & bars
    for(ll i=0;i<=l;i++){
        // a + i >= b + c + k + j
        // a + i - b - c >= k + j
        // l - i >= k + j
        x=min(a+i-b-c,l-i);
        if(x>=0)res-=(x+2)*(x+1)/2;
        x=min(b+i-a-c,l-i);
        if(x>=0)res-=(x+2)*(x+1)/2;
        x=min(c+i-b-a,l-i);
        if(x>=0)res-=(x+2)*(x+1)/2;
    }
    cout<<res;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

long long int func(long int x,long int y,long int z,long int k)
{
long long int var;
	var = (x+k-(y+z));

//	cout << "i " << k << "var " << var << endl;
	if(var >= 0)
{	var /= 2;
	return ((var+1)*(var+2))/2;}
	else
		return 0;
}
int main()
{
long long int a,b,c,k,i,ans,total,sub;
long long int x=3;long long int y=4;
long long int z = (x-y)/2;
//cout << "z " << z << endl;

cin >> a >> b >> c >> k;
ans = 0;
for(i=0;i<=k;i++)
{	sub = 0;

	total = ((i+2)*(i+1))/2;
//	cout << total << endl;

	sub += func(a,b,c,i);

	sub += func(b,a,c,i);
	sub += func(c,a,b,i);
//	cout << sub << endl;
	if((total - sub )>=0)

	ans += total - sub;
//	cout << "i : "<< i << " ans : " << total - sub << endl;
//	cout << "i : " << i << " " << total - sub << endl;

}
cout << ans << endl;
return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define sp ' '
#define en '\n'
#define fi first
#define se second

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair <int, int> pii;

ll solve(ll a, ll b, ll c, ll l)
{
    ll t = a - b - c;
    ll ans = 0;
    for(int i = 0; i <= l; i ++)
    {
        ll tp = min(l - i, t + i);
        if(tp < 0)continue;
        ans += (tp + 2)*(tp + 1) / 2;
    }
    return ans;
}

int main ()
{
    ll a, b, c, l;
    cin >> a >> b >> c >> l;

    ll ans = (l + 3)*(l + 2)*(l + 1) / 6;
    ans -= solve(a, b, c, l);
    ans -= solve(b, a, c, l);
    ans -= solve(c, a, b, l);

    cout << ans;
}

/*

*/

#define fi first
#define infInt 2147483647
#define infLongInt 2147483647
#define infLongLongInt 9223372036854775807
#define ll long int
#define lld long long int
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define sz(x) ((int)(x.size()))
#define IN(x,y) ((y).find((x))!=(y).end())
#define PI 3.14159265
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=1;i<=(n);i++)
#define repd(i,a,b) for (int i = (a); i <= int(b); i++)
#define revd(i,a,b) for (int i = (a); i >= int(b); i--)
#define se second
#define newline cout<<endl;
#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
using namespace std;
template<typename T>
T max1(T a,T b)
{
  return a>b ? a :b;
}
template<typename T>
T min1(T a,T b)
{
  return a<b ? a :b;
}
template<typename T>
T max1(T a,T b,T c)
{
  return max1(a,max1(b,c));
}
template<typename T>
T min1(T a,T b,T c)
{
  return min1(a,min1(b,c));
}
template<typename T>
T abs1(T a,T b)
{
  return a>b ? a-b : b-a;
}
template<typename T>
void swap1(T &a,T &b)
{
  T temp = b;
  b = a;
  a = temp;
}
template<typename T>
void swap1(T a[],int i,int j)
{
  T temp = a[i];
  a[i] = a[j];
  a[j] = temp;
}
template<typename T,typename P>
void reset(T array[],int size,P value)
{
  rep(i,size) array[i] = value;
}
template<typename T,typename P>
void reset(T *array,int rows,int cols,P value)
{
  rep(i,rows)
    rep(j,cols)
      *(array + i * cols + j) = value;
}
template<typename T>
void resetClear(T v[],int size)
{
  for(int i = 0;i < size;i++)
    v[i].clear();
}
template<typename T>
T maxArr(T array[],int start,int ending)
{
  T res = array[start];
  repd(i,start,ending) res = max1(array[i],res);
  return res;
}
template<typename T>
T maxArr(T array[],int ending)
{
  T res = array[0];
  rep(i,ending) res = max1(array[i],res);
  return res;
}
template<typename T>
T minArr(T array[],int start,int ending)
{
  T res = array[start];
  repd(i,start,ending) res = min1(array[i],res);
  return res;
}
template<typename T>
T minArr(T array[],int ending)
{
  T res = array[0];
  rep(i,ending) res = min1(array[i],res);
  return res;
}
template<typename T,typename P=lld>
P sumArr(T array[],int ending)
{
  P res = 0;
  rep(i,ending) res = res + array[i];
  return res;
}
template<typename T,typename P=lld>
P sumArr(T array[],int ending,P mod)
{
  P res = 0;
  rep(i,ending) res = (res + array[i])%mod;
  return res;
}
int stringToNum(string &number)
{
  int num = 0;
  int mul = 1;
  for (int i = sz(number)-1; i >=0 ; --i)
  {
    num = num  + (number[i]-'0')*mul;
    mul = mul *10;
  }
  return num;
}
int bit(lld num)
{
  int res = 0;
  for (lld i = 0; (1ll << i) <= num ; ++i) res = i;
  return res;
}
const int MAXN = 100000 + 10;
const int MAXM = 100000 + 10;
const int MAXLOG = 18;
int t,n,k;
lld a,b,c,l;
lld sol()
{
  lld ways = 0;
  rep(la,l+1)
  {
    lld x = min(a-b-c+la,l-la);
    if(la + a >= b+c)
      ways = ways + ((x+1)*(x+2))/2;
    x = min(b-a-c+la,l-la);
    if(la + b >= a+c)
      ways = ways + ((x+1)*(x+2))/2;
    x = min(c-b-a+la,l-la);
    if(la + c >= a+b)
      ways = ways + ((x+1)*(x+2))/2;
  }
  lld ans = ((l+1)*(l+2)*(l+3))/6;
  ans = ans - ways;
  return max(0ll,ans);
}
int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  cin >> a >> b >> c >> l;
  lld ans = sol();
  cout << ans << endl;
  return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
#define LL __int64
LL sum[300100] ;
LL solve(int a,int b,int c,int l) {
    if( a < b+c ) return (LL)0 ;
    LL ans = min(a-b-c,l) ;
    return (ans+1)*(ans+2)/2 ;
}
int main() {
    int a , b , c , l ;
    LL i , ans ;
    while( scanf("%d %d %d %d", &a, &b, &c, &l) != EOF ) {
        sum[0] = 1 ;
        for(i = 1 ; i <= l ; i++) {
            sum[i] = (i+1)*(i+2)/2 + sum[i-1] ;
        }
        ans = sum[l] ;
        for(i = 0 ; i <= l ; i++) {
            ans -= solve(a+i,b,c,l-i) ;
            ans -= solve(b+i,a,c,l-i) ;
            ans -= solve(c+i,a,b,l-i) ;
        }
        printf("%I64d\n", ans) ;
    }
    return   0 ;
}

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef __int64 lld;

int a, b, c, l;

void work() {
    scanf("%d%d%d%d", &a, &b, &c, &l);
    lld ans = 0;
    for (int i = 0; i <= l; i++) {
        lld s = a + b + c + i;
        lld _max = (s - 1) / 2;
        if (a > _max || b > _max || c > _max) {
            continue;
        }
        ans += 1LL * (i + 2) * (i + 1) / 2;
        lld A[] = {a, b, c};
        for (int j = 0; j < 3; j++) {
            if (A[j] + i > _max) {
                lld now = s - _max;
                ans -= (i - (_max + 1 - A[j]) + 2) * (i - (_max + 1 - A[j]) + 1) / 2;
            }
        }
    }
    printf("%I64d\n", ans);
    return ;
}

int main() {
    work();
    return 0;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
int a, b, c, l, ans;
signed main() {
    cin >> a >> b >> c >> l;
    for (int i = 1; i <= l; i++) ans += (i + 1) * (i + 2) / 2;
    for (int i = max((long long)0, a + b - c); i <= l; i++)
        ans -= (min(c - b - a + i, l - i) + 1) * (min(c - b - a + i, l - i) + 2) / 2;
    for (int i = max((long long)0, b + c - a); i <= l; i++)
        ans -= (min(a - b - c + i, l - i) + 1) * (min(a - b - c + i, l - i) + 2) / 2;
    for (int i = max((long long)0, a + c - b); i <= l; i++)
        ans -= (min(b - a - c + i, l - i) + 1) * (min(b - a - c + i, l - i) + 2) / 2;
    cout << ans + 1;
}

#include <bits/stdc++.h>
#define NMAX 300003
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
ll C(ll a, ll b){
    ll ans=1;
    for(ll i=a-b+1;i<=a;i++) ans*=i;
    for(ll i=2;i<=b;i++) ans/=i;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll a,b,c,l;
    cin>>a>>b>>c>>l;
    ll ans=C(l+3,3);
    for(ll add=0;add<=l;add++){
        if(a+add<b+c) continue;
        ll toadd=min(l-add,a+add-b-c);
        ans-=(toadd+1)*(toadd+2)/2;
    }
    for(ll add=0;add<=l;add++){
        if(b+add<a+c) continue;
        ll toadd=min(l-add,b+add-a-c);
        ans-=(toadd+1)*(toadd+2)/2;
    }
    for(ll add=0;add<=l;add++){
        if(c+add<b+a) continue;
        ll toadd=min(l-add,c+add-b-a);
        ans-=(toadd+1)*(toadd+2)/2;
    }
    cout<<ans;
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 2000000
#define INF 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    a b c
    increase each stick, sum <= l
    can not increase any stick

    INPUT
        a b c l (a,b,c: 1->3e5, l: 0->3e5)
    OUPUT
        number of way increase

 Idea
    a+x + b+y <= c+z
        x, y => find how many z

    f(a,b,c,l)
        g(a,b,c+i, l-i)

    x, y, z
    x+y+z <= l
    a <= x < l/2
    b <= y < l/2
    c <= z < l/2

    f(x, y) = (|x-y| + 1, c)  (|x+y| - 1, l-x-y)
    f(x, y:1)

    x+y = u
    x: a->u-b
    |x-y| => |u - 2a| => |u-2b|

    x+y = u

    triangle
        range(max(c, |x-y| + 1), min(x+y-1, l-x-y))

    each x-y = d

    ways(u) ways(u) x,y,z x+y = u and satisfy conditions
        x: a => y = u-a  triangle(a,u-a)
        y:b => x = u-b   triangle(u-b,b)

        u-2 > z => ways(u-2, l-2)
        x-1, y-1 z

        z = u-1 <= l-u => range(a, u-b)
        z = u-2 <= l-u => range(max(a,2), min(u-b, u-2))

    ways(a+b) = triangle(a,b)
    ways(a+b+1) = triangle(a+1, b) + triangle(a, b+1);

    ways(u, l) = ways(u-2, l-2) + C;
    ans(l) = ways(a+b) + ways(a+b+1) + ans(l-2) + sum(C)

    g(l) = sum(ways(i, l)) 1:a+b->l

 Seond Idea
 ways(u) x+y+z <= l
    x = a || y = b
        x = a
            u[i] = u[i-1] + pair(i-a, a, b, c), i:1->l
        y = b
            v[i] = v[i-1] + pair(i-b, b, a, c), i:1->l
        x = a && y = b
            triangle(a, b)

    z = x+y-1
        2x+ 2y <= l + 1
        t[i]
            t[i-1] l even
            t[i-1] + range(a+1, (i+1)/2 - b-1)
            i: 1->l
            (l+1)/2-1>=c

    z = x+y-2
        2x + 2y <= l + 2    y[l]
        w[i]
            w[i-1] l even
            w[i-1] + range(a+1, (i+2)/2 - b-1)
            i: 1->l

    pair (sum, dif, a, b)
        range( max(ceil((sum-dif)/2.0), a), min((sum+dif)/2, sum-b))

 ways(i) = ways(i-2) + u[i] + v[i] - range(max(abs(a-b) + 1, c), min(a+b-1, i-a-b)) + t[i] + w[i]

    Complexity(O(N))

 Test
 1 1 1 5

 i:2
    u[3] = getPair(2,2,1,1) = 1
    v[3] = getPair(2,1,1,1) = 1
    t[3] = getPair(2, INF, 1, 1) = 1
    x, y , z = 1
    w[3] = getPair(2, INF, 2, 2) = 0

    ways[3] = 1 + 1 - 1 + 0 + 0

    u[4] = u[3] + getPair(3,0,1,1) = 1
    v[4] = 1

    t[4] = getPair(2, INF, 1 , 1)

 */

int range(int x, int y){
    return max(y-x+1, 0);
}

int getPair(int sum, int other, int a, int b){
    if (sum <= other) return 0;
    int dif = other - 1;
    return range(max((int)ceil((sum-dif)/2.0), a), min((sum+dif)/2, sum-b));
}

ll u[N]{0}, v[N]{0}, w[N]{0}, t[N]{0}, ways[N]{0};

int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int a,b,c,l;
    cin >> a >> b >> c >> l;

    l = l + a + b + c;
    go(i,2,l){
        u[i] = u[i-1] + getPair(i-a, a, b, c);
        v[i] = v[i-1] + getPair(i-b, b, a, c);
        t[i] = t[i-1];
        if(i%2 == 1 && (i+1)/2-1>=c) t[i] += range(a+1, (i+1)/2 - b - 1);
        w[i] = w[i-1];
        if(i%2 == 0 && (i+2)/2-2>=c) w[i] += range(a+1, (i+2)/2 - b - 1);
        ways[i] = ways[i-2] + u[i] + v[i] - range(max(abs(a-b) + 1, c), min(a+b-1, i-a-b)) + t[i] + w[i];
//        cout << i << " " << u[i] << endl;

    }
    cout << ways[l] << endl;
    return 0;
}

#include<bits/stdc++.h>
long long a,b,c,l,ans=0;
inline long long count(long long x,long long y,long long z,long long L){
    long long ret=0,now;
    for(register long long i=std::max(0LL,x+y-z);i<=L;++i)now=std::min(L-i,z+i-x-y),ret+=(now+1)*(now+2)/2;
    return ret;
}
int main(){
    scanf("%lld%lld%lld%lld",&a,&b,&c,&l);++ans;
    for(register long long i=1;i<=l;++i)ans+=(i+1)*(i+2)/2;
    ans-=count(a,b,c,l);ans-=count(a,c,b,l);ans-=count(c,b,a,l);
    printf("%lld\n",ans);
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
long long dp[300300];

void init()
{
	for(long long i = 0; i<300300; i++) dp[i] = (i + 1ll)*(i + 2ll) / 2ll;
}

int main()
{
	init();
	long long a, b, c, l;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &l);
	long long ans = ((l + 1ll)*(l + 2ll)*(l + 3ll))/6ll;

	for(long long la = 0ll; la <= l; la++)
	{
		int x = (int)min(l - la, a + la - (b + c));
		if(x>=0) ans -= dp[x];
	}

	for(long long lb = 0ll; lb <= l; lb++)
	{
		int x = (int)min(l - lb, b + lb - (c + a));
		if(x>=0) ans -= dp[x];
	}

	for(long long lc = 0ll; lc <= l; lc++)
	{
		int x = (int)min(l - lc, c + lc - (a + b));
		if(x>=0) ans -= dp[x];
	}

	printf("%lld\n", ans);
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int solve(int A, int B, int C, int L) {
	int res = 0;
	for (int i = 0; i <= L; i++) {
		int a = A + i - B - C;
		int t = min(a, L - i);
		if(t >= 0)res += (t + 2)*(t + 1) / 2;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C, L;
	cin >> A >> B >> C >> L;
	int res = 0;
	for (int i = 0; i <= L; i++) {
		res += (L - i + 2) * (L - i + 1) / 2;
	}
	//cerr << res << endl;
	res -= solve(A, B, C, L);
	res -= solve(B, C, A, L);
	res -= solve(C, A, B, L);

	cout << res << endl;
}

#include <iostream>
#include <cstdio>

using namespace std;

const int Dim = 1e6 + 5;

long long dp1[ Dim ], dp2[ Dim ], dp3[ Dim ], s1[ Dim ], s2[ Dim ], s3[ Dim ];
long long a, b, c, l;

long long NrTotal, NrGresit, NrCorect;

void prec () {
    dp1[0] = 1, s1[0] = 1;
    for (int i = 1; i <= l; ++i) {
        dp1[i]= 1;
        s1[i] = s1[i - 1] + dp1[i];
    }

    dp2[0] = s2[0] = 1;
    for (int i = 1; i <= l; ++i) {
        dp2[i] = s1[i];
        s2[i] = s2[i - 1] + dp2[i];
    }

    dp3[0] = s3[0] = 1;
    for (int i = 1; i <= l; ++i) {
        dp3[i] = s2[i];
        s3[i] = s3[i - 1] + dp3[i];
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen ("input.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    cin >> a >> b >> c >> l;

    prec ();
    NrTotal = s3[l];

    for (int i = 0; i <= l; ++i) {
        long long d = min(a + i - b - c, l - i);
        if (d < 0)
            continue;

        NrGresit += (d + 1) * (d + 2) / 2;
    }

    for (int i = 0; i <= l; ++i) {
        long long d = min(b + i - a - c, l - i);
        if (d < 0)
            continue;

        NrGresit += (d + 1) * (d + 2) / 2;
    }

    for (int i = 0; i <= l; ++i) {
        long long d = min (c + i - a - b, l - i);
        if (d < 0)
            continue;

        NrGresit += (d + 1) * (d + 2) / 2;
    }

    NrCorect = NrTotal - NrGresit;
    cout << NrCorect << '\n';

    return 0;
}

//#pragma comment(linker,"/STACK:102400000,102400000")
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<time.h>
#include<stdlib.h>
#include<ctype.h>
#include<float.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define PF push_front
#define lson k<<1
#define rson k<<1|1
typedef long long ll;
typedef double db;
typedef const db cdb;

const db eps=1e-6;
const db INF=DBL_MAX;

bool iszero(cdb a){return fabs(a)<=eps;}
db sqr(cdb a){return a*a;}
int sgn(cdb a){if(a<-eps)return -1;return (a>eps);}
int cmp(cdb a,cdb b){return sgn(a-b);}
int inint(){
	int t;scanf("%d",&t);
	return t;
}
int sgn(ll a){return a>0?1:(a<0?-1:0);}

ll a,b,c,l;

ll solve1(){
    ll res=0;
    for(ll i=2;i<=l+2;i++){
        res+=((i*(i-1))>>1);
    }
    return res;
}

ll solve2(ll a,ll b,ll c,ll l){
    if(b+c>a) return 0;
    ll res=min(a-b-c,l)+2;
    return (res*(res-1))>>1;
}

void solve(){
    scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&l);
    ll ans=solve1();
    for(int i=0;i<=l;i++){
        ans-=solve2(a+i,b,c,l-i);
        ans-=solve2(b+i,a,c,l-i);
        ans-=solve2(c+i,b,a,l-i);
    }
    printf("%I64d\n",ans);
}

int main(){
    solve();
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <string.h>
#include <string>
#include <limits.h>
#include <algorithm>
#include <set>
#include <ctime>
#include <cmath>
#include <assert.h>
using namespace std;
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a; i<(int)n; i++)
#define per(i,n,a) for (int i=n; i>=a; i--)
#define hk push_back
#define pk pop_back
#define mp make_pair
#define PI 3.141592653589793
#define clr(a) memset(a, 0, sizeof(a))
#define clr1(a) memset(a, -1, sizeof(a))
typedef vector<int> VI;
typedef vector< pair<int, int> > VIP;
typedef vector< pair<int, pair<int, double> > > VIPP;
typedef vector<string> VS;

typedef vector <double> VD;
typedef vector <bool> VB;
typedef long long ll;
#define MAX_V 1000
const ll mod = 1000000007;
ll powmod(ll a, ll b) {
    ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res;
}

ll a, b, c, L;

ll getSum(ll k) {
    if (k < 0) return 0;
    return (k * (k + 1)) / 2;
}

int main()
{
    cin >> a >> b >> c >> L;
    ll retAll = 0;
    rep(l, 0, L + 1) {
        if (l <= (l + c - a - b) / 2.) continue;
        if (b + c + l - a <= 0 || a + c + l - b <= 0) continue;
        ll ret = getSum(l + 1);
        ret -= getSum(l + 1 - (b + c + l - a + 1) / 2);
        ret -= getSum(l + 1 - (a + c + l - b + 1) / 2);
        ret -= getSum((l + c - a - b + 2) / 2);
        retAll += ret;
    }

    cout << retAll << endl;

    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair <int, int>
#define vi vector<int>

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define FORd(i, a, b) for (int i=a-1; i>=b; i--)
#define F0Rd(i, a) for (int i=a-1; i>=0; i--)
#define F0R(i, a) for (int i=0; i<a; i++)

#define f first
#define s second
// #define b begin
#define e end
#define lb lower_bound
#define ub upper_bound
#define sz size

const int MOD = 1000000007;
double PI = 4*atan(1);

ll a,b,c,l,ans = 0;

void solve() {
	F0R(i,l+1)
		if (l-i >= max((ll)0,(a+b-c+i)))
			ans -= (i+1)*(l-i-max((ll)0,(a+b-c+i))+1);
}

int main() {
	cin >> a >> b >> c >> l;
	ans = (l+3)*(l+2)*(l+1)/6;
	solve();
	swap(a,c);
	solve();
	swap(b,c);
	solve();
	cout << ans;
	// z >= a+x+b+y-c
	// x+y+z<= l
	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
int a,b,c,l;
long long sum=1;

long long calc(int x,int y,int z,int rest)
{
	if(x<y+z)
		return 0ll;
	long long res=std::min(x-y-z,rest);
	return (res+1)*(long long)(res+2)>>1;
}

int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&l);
	for(int i=1;i<=l;i++)
		sum=sum+((i+1)*(long long)(i+2)>>1ll);
	for(int i=0;i<=l;i++)
	{
		sum-=calc(a+i,b,c,l-i);
		sum-=calc(b+i,c,a,l-i);
		sum-=calc(c+i,a,b,l-i);
	}
	printf("%lld\n",sum);
	return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5+10;
typedef long long ll;
ll a, b, c, l, maxn;

ll sol(ll x, ll y, ll z)
{
	ll tmp = 0;
	for(ll i = x; i <= x+l; i++)
	{
		if((y + z) <= i)
		{
			ll cnt = min(i, maxn - i) - y - z;
			tmp += (cnt + 1) * (cnt + 2) / 2;
		}
	}
	return tmp;
}

int main()
{
	while(~scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &l))
	{
		maxn = a + b + c + l;
		ll ans = 0;
		for(ll i = 2; i <= l+2; i++)
		{
			ans += (i * (i - 1)) / 2;
		}
		ans -= sol(a, b, c);
		ans -= sol(b, a, c);
		ans -= sol(c, a, b);
		printf("%I64d\n", ans);
	}
	return 0;
}

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

typedef long long ll;

ll a, b, c, l;

ll solve(ll x) {
    if(x < 0) return 0;
    return (x + 1) * (x + 2) / 2;
}

int main() {
    cin >> a >> b >> c >> l;
    ll res = 1LL * (l + 1) * (l + 2) * (l + 3) / 6;
    for(int i = 0; i <= l; i++) {
        res -= solve(min(a + i - b - c, l - i));
        res -= solve(min(b + i - a - c, l - i));
        res -= solve(min(c + i - a - b, l - i));
    }
    cout << res << endl;

}

#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using ll = long long;
using namespace std;
const int maxn = 1<<17, mod = 1e9 + 7;
int a, b, c, l;
signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> a >> b >> c >> l;
	ll ans = 0;
	for(ll x = 0; x <= l; x++) {
		ans += (x+2)*(x+1)/2;
		ll s = a+b+c+x;
		s = (s+1)/2;
		for(int t : {max(0ll, s-a), max(0ll, s-b), max(0ll, s-c)}) {
			ll u = x-t;
			//cout << u << endl;
			if(u >= 0) ans -= (u+2)*(u+1)/2;
		}
		//cout << a << " " << b << " "<< c << " " << x << " " << ans << endl;
	}
	cout << ans << endl;
}

using namespace std;
#include<cstdio>
#include<iostream>
typedef long long LL;
int a, b, c, l;

LL sol(int a, int b, int c, int l){
    LL res = 0;
    for(int i=max(0, b+c-a); i<=l; ++i){
        int m = min(l-i, a+i-b-c);
        res += LL(m+1)*(m+2)/2;
    }
    return res;
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("xx.inp", "r", stdin);
        freopen("yy.out", "w", stdout);
    #endif // ONLINE_JUDGE

    cin >> a >> b >> c >> l;
    LL t, x, y, z;
    t = (LL)(l+1)*(l+2)*(l+3)/6;
    x = sol(a, b, c, l);
    y = sol(b, a, c, l);
    z = sol(c, a, b, l);

    cout << t-x-y-z << endl;

    return 0;
}

#include <iostream>

using namespace std;

typedef long long ll;

// ways where a=b=c
ll count3(ll a, ll b, ll c, ll n) {
  ll m = max(a, max(b, c));
  ll used = (m-a) + (m-b) + (m-c);
  if(n < used) { return 0; }
  return 1 + (n-used)/3;
}

// ways where a=b is max
ll count2(ll a, ll b, ll c, ll n) {
  ll ans = 0;

  ll m = max(a, b);
  ll used = (m-a) + (m-b);
  for(ll i=0; 2*i+used<=n; i++) {
    ll M = m + i;
    if(M>c) {
      ans += min(M-1-c+1, n-used-2*i+1);
    }
  }
  return ans;
}
// # of (a, b) s.t. 0<=a<=A && 0<=b<=B && a+b<=C
ll _count(ll A, ll B, ll C) {
  if(A<0 || B<0 || C<0) { return 0; }
  A = min(A, C);
  B = min(B, C);
  if(A==0 && B<=C) { return B+1; }
  if(A>0 && A+B<C) { return (A+1)*(B+1); }
  if(A>0 && C<B) { return -((A+1)*(A-2*(C+1)))/2; }
  if(A==0 && B>C) { return C+1; }
  if(B==C && A>0) { return B+1+A*C + (A-A*A)/2; }
  if(A>0 && B<C && A+B==C) { return (B+1)*(C-B+1); }
  return (-A*A + 2*A*C + A + (B-C)*(B-C) + 2*C*(B-C) + (2*B+1)*(C-B) + 2*B + 2)/2;
}
// # of (a, b) s.t. 0<=a<=A && 0<=b<=B && C<=a+b<=D
ll count(ll A, ll B, ll C, ll D) {
  if(A<0 || B<0 || D<0) { return 0; }
  if(C < 0) { C=0; }
  if(C > D) { return 0; }
  return _count(A, B, D) - _count(A, B, C-1);
}
int main() {
  ll a, b, c, n;
  cin >> a >> b >> c >> n;

  ll ans = 0;
  for(ll i=0; i<=n; i++) {
    ll A = a+i;
    if(A>b && A>c) {
      ans += count(A-1-b, A-1-c, A-b-c+1, n-i);
    }

    ll B = b+i;
    if(B>a && B>c) {
      ans += count(B-1-a, B-1-c, B-a-c+1, n-i);
    }

    ll C = c+i;
    if(C>a && C>b) {
      ans += count(C-1-a, C-1-b, C-a-b+1, n-i);
    }
  }

  ans += count2(a, b, c, n);
  ans += count2(a, c, b, n);
  ans += count2(b, c, a, n);
  ans += count3(a, b, c, n);
  cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll cal(ll a, ll b, ll c, ll l) {
  ll ret = 0;
  for (int i = 0; i <= l; i++) {
    ll t = min(l - i, a + i - b - c);
    if (t >= 0) ret += (t + 1) * (t + 2) / 2;
  }
  return ret;
}

int main(int argc, char *argv[]) {
  ll a, b, c, l;
  cin >> a >> b >> c >> l;
  ll ans = (l + 1) * (l + 2) * (l + 3) / 6;
  cout << ans - cal(a, b, c, l) - cal(b, a, c, l) - cal(c, a, b, l) << endl;
  return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cctype>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <fstream>
#define debug "output for debug\n"
#define pi (acos(-1.0))
#define eps (1e-8)
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 100005;
ll check(ll a)
{
    return (a+1)*(a+2)/2;
}
int main()
{
    ll sum;
    ll a,b,c,l;
    while(scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&l)!=EOF)
    {
        sum=(l+1)*(l+2)*(l+3)/6;
        for(ll i=0;i<=l;i++)
           {
        if (a + i >= b + c) sum=sum-check(min(l - i, a + i - b - c));
        if (b + i >= a + c)sum=sum-check(min(l - i, b + i - a - c));
        if (c + i >= a + b)sum=sum-check(min(l - i, c + i - a - b));
           }
        printf("%I64d\n",sum);
    }
    return 0;

}

#include <cstdio>
#include <algorithm>
using namespace std;
long long int solve(long long int a)
{
    return (a + 1) * (a + 2) / 2;
}
int main()
{
    long long int a, b, c, l;
    while (scanf("%lld%lld%lld%lld", &a, &b, &c, &l) != EOF)
    {
        long long int num = (l + 1) * (l + 2) * (l + 3) / 6;
        for (int i = 0; i <= l; i++)
        {
            if (a + i >= b + c)
            {
                num -= solve(min(l - i, a + i - b - c));
            }
            if (b + i >= a + c)
            {
                num -= solve(min(l - i, b + i - a - c));
            }
            if (c + i >= a + b)
            {
                num -= solve(min(l - i, c + i - b - a));
            }
        }
        printf("%lld\n", num);
    }
    return 0;
}

#include<cstdio>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
using namespace std;
typedef long long ll;
typedef double db;
void gn(int &x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');
    if(c=='-')sg=-1,x=0;else x=c-'0';
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';
    x*=sg;
}
void gn(ll &x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');
    if(c=='-')sg=-1,x=0;else x=c-'0';
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';
    x*=sg;
}
const int mo=1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int a,b,c,l;

ll work2(int l){
    if(l<0)return 0;
    return 1ll*(l+1)*(l+2)/2;
}
ll work(int a,int d,int l){
    ll an=0;
    for (int i=0;i<=l;i++)an+=work2(min(l-i,a+i-d));
    return an;
}
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&l);
    ll to=1ll*(l+1)*(l+2)*(l+3)/6;
    to-=work(a,b+c,l);
    to-=work(b,a+c,l);
    to-=work(c,a+b,l);
    cout<<to<<endl;
    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
int a,b,c,l,a1,b1,c1,l1;
long long ans=0;
int main()
{
    int i,j,k;
    scanf("%d%d%d%d",&a,&b,&c,&l);
    if(b<c) swap(b,c);
    for(i=0;i<=l;i++)
    {
        a1=a+i;
        b1=b,c1=c,l1=l-i;
        if(a1==1)
        {
            l1-=b1-c1;
            if(l1>=0) ans+=l1/2+1;
            continue;
        }
        if(b1+c1<=a1)
        {
            l1-=a1-b1-c1+1;
            b1=a1-c1+1;
        }
        if(b1-c1>=a1)
        {
            l1-=b1-a1+1-c1;
            c1=b1-a1+1;
        }
        if(l1<0) continue;
        j=min(c1+a1-1,b1+l1);
        ans+=1LL*(b1+j+2-2*b)*(j-b1+1)/2;
        if(b1+l1-c1>=a1)
        {
            l1-=c1+a1-b1-1;
            j=min(l1,(b-c1)*2);
            if(j%2==0) ans+=1LL*(c1+a1-b+c1+a1-b+1+c1+a1-b+j-1+c1+a1-b+1-1)*j/4;
            else
            {
                ans+=c1+a1-b;
                if(j>1) ans+=1LL*(c1+a1-b+1+c1+a1-b+1+c1+a1-b+j/2+c1+a1-b+j/2)*(j/2)/2;
            }
            l1-=2*(b-c1);
            if(l1>0) ans+=1LL*(l1+1)/2*(a1-1)+1LL*l1/2*a1;
        }
    }
    printf("%I64d\n",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define f(x, y, z) for (int x = (y), _end_ = z; x <= _end_; ++x)
#define g(x, y, z) for (int x = (y), _end_ = z; x >= _end_; --x)
#define fe(x, y, z) for (int x = (y), _end_ = z; x < _end_; ++x)
#define ge(x, y, z) for (int x = (y), _end_ = z; x > _end_; --x)
#define ms(a, b) memset(a, b, sizeof (a));
typedef long long ll;
template <typename Num> void write(Num x);
template <typename Num> void read(Num &x);

// Define Varibles :
ll a, b, c, l;
ll tot;
ll la, lb, lc, x;
// Define Functions :

int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	cin >> a >> b >> c >> l;
	tot = (l + 1) * (l + 2) * (l + 3) / 6;
	for (la = 0; la <= l; la++) {
		x = min(la + a - b - c, l - la);
		if (x >= 0) tot -= (x + 1) * (x + 2) / 2;
	}
	for (lb = 0; lb <= l; lb++) {
		x = min(lb - a + b - c, l - lb);
		if (x >= 0) tot -= (x + 1) * (x + 2) / 2;
	}
	for (lc = 0; lc <= l; lc++) {
		x = min(lc - a - b + c, l - lc);
		if (x >= 0) tot -= (x + 1) * (x + 2) / 2;
	}
	cout << tot << endl;
	return 0;
}

template <typename Num> void read(Num &x) {
	char c; int flag = 1;
	while ((c = getchar()) < '0' || c > '9') if (c == '-') flag *= -1;
	x = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') x *= 10, x += c - '0';
	x *= flag;
}

template <typename Num> void write(Num x) {
	if (x == 0) { putchar('0'); return; }
	static int s[20]; int sl = 0;
	if (x < 0) putchar('-'), x = -x;
	while (x) s[sl++] = x % 10, x /= 10;
	while (sl--) putchar(s[sl] + '0');
}

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define MAXN 101010
#define LOGN 18
#define EPS 1e-8
#define fcin ios_base::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll ans;

void conta(int a, int b, int c, int l){
	rep(i,0,l+1){
		int maior = a+i;
		int pode = min(l-i, maior-b-c);
		if(pode < 0) continue;
		ans -= (ll)(pode+1)*(pode+2)/2;
	}
}

int main(){
	int a, b, c, l;
	scanf("%d%d%d%d", &a, &b, &c, &l);
	ans = (ll)(l+1)*(l+2)*(l+3)/6;
	conta(a,b,c,l);
	conta(b,a,c,l);
	conta(c,a,b,l);
	printf("%lld\n", ans);
}

#include<bits/stdc++.h>
using namespace std;
long long a,b,c,l,ans;
void did(long long lastlen){
	ans=ans-(lastlen+2)*(lastlen+1)/2;
}
int main(){
	cin>>a>>b>>c>>l;
	ans=(l+3)*(l+2)*(l+1)/6;
	for(long long i=0;i<=l;i++){
		if(a+i>=b+c)did(min(i,i-(a+b+c+i+1)/2+a));
		if(b+i>=a+c)did(min(i,i-(a+b+c+i+1)/2+b));
		if(c+i>=a+b)did(min(i,i-(a+b+c+i+1)/2+c));
	}
	cout<<ans;
}

#include <iostream>
#include <cstdio>
using namespace std;
typedef  long long ll;
ll dm(ll x,ll y,ll z,ll l)
{
	ll res=0,now=0;
	for(ll i=max((ll)0,x+y-z);i<=l;i++)
	{
		now=min(l-i,z+i-x-y);
		res+=(now+1)*(now+2)/2;
	}
	return res;

}
int main()
{
   ll a,b,c,l;
   unsigned long long ans=1;
   cin>>a>>b>>c>>l;
   for(ll i=1;i<=l;i++)
   	ans+=(i+1)*(i+2)/2;
   	ans-=dm(a,b,c,l);
   	ans-=dm(a,c,b,l);
   	ans-=dm(b,c,a,l);
   	cout<<ans<<endl;
	return 0;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define mem(a,b) memset(a,b,sizeof(a))
const int maxn = 5e5+5;
const int ff = 0x3f3f3f3f;
const double esp = 1e-7;

ll a,b,c,l;
ll ans;

ll exc(ll x,ll y,ll z,ll len)
{
	ll sum = 0;
	for(ll i = max((ll)0,y+z-x);i<= len;i++)
	{
		ll tmp = min(len-i,x+i-y-z)+2;
		sum+= (tmp-1)*tmp/2;
	}
	return sum;
}

int main()
{
	cin>>a>>b>>c>>l;
	ans = (l+3)*(l+2)*(l+1)	/ 6;
	ans-= exc(a,b,c,l);
	ans-= exc(b,a,c,l);
	ans-= exc(c,a,b,l);

	cout<<ans<<endl;
	return 0;
}

// monera
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i =a; i <=b ; i++)
#define all(a) a.begin(),a.end()
#define ff first
#define ss second
#define sqr(x) ((x)*(x))
#define EPS 1e-9
#define db(var) cout<<var<<" ";
#define el cout<<endl;
#define p(A,a,b)  f(i,a,b) cout<<A[i]<<" ";
#define sj  cout<<"OK"<<endl;
#define ll long long int

//functions
#define count_1(n)    __builtin_popcountll(n)
#define gcd(a,b) __gcd(a,b)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )

#define MOD 1000000007
#define PI acos(-1.0)
#define e exp(1.0)
#define EPS 1e-9
#define INF    2047483647
#define INFLL  9023372036854775807LL

using namespace std;

ll solve(ll a,ll b,ll c,ll l)
{
    if(a<b+c)       // triangle formed return
    return 0;

    ll ret;
    ll rem=min(l,a-b-c);

    ret=(rem+1)*(rem+2)/2; // number of ways to distribute rem between b,c,nothing

    return ret;

}

int main()
{
    ios :: sync_with_stdio(0);

    ll a,b,c,l;
    cin>>a>>b>>c>>l;

    ll ans=(l+1)*(l+2)*(l+3)/6;      // total ways of distributing l among 4 bins (a,b,c,do nothing) (l+3)C(3)

    for(ll i=0;i<=l;i++)       // increase value of each length from 0 to l and find ways of not forming a triangle
    {
        ans-=solve(a+i,b,c,l-i);
        ans-=solve(b+i,a,c,l-i);
        ans-=solve(c+i,b,a,l-i);
    }

    cout<<ans<<endl;

  return 0;
}

using namespace std;
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <algorithm>

typedef long long int lli;

lli v[3], l, total;

int main(){

    cin >> v[0] >> v[1] >> v[2] >> l;

    total = ((l+3)*(l+2)*(l+1))/6;

    for(int i = 0;i < 3;i++){
        for(int s = 0;s <= l;s++){
            if(s+v[i] >= v[(i+1)%3]+v[(i+2)%3]){
                lli x = min(l-s, v[i]-v[(i+1)%3]-v[(i+2)%3]+s);

                total -= ((x+1)*(x+2))/2;
            }
        }
    }

    cout << total << endl;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define int long long

int C(int n, int r)
{
	if (r > n)
		return 0;
	int ans = 1;
	for (int i = n - r + 1; i <= n; i++)
		ans *= i;
	for (int i = 1; i <= r; i++)
		ans /= i;
	return ans;
}

main()
{
	int a, b, c, l;

	cin >> a >> b >> c >> l;

	int A = C(l+3, 3);//total ways to add on a, b, c with sum at most l without considering if it results a triangle
	int B = 0;//number of ways which doesn't result a triangle

	for(int i = 0; i <= l; i++) {//i is the amount added on the first stick
		int x = min(a - b - c + i, l - i);
		B += C(x + 2, 2);
	}

	for(int i = 0; i <= l; i++) {//i is the amount added on the second stick
		int x = min(b - a - c + i, l - i);
		B += C(x + 2, 2);
	}

	for(int i = 0; i <= l; i++) {//i is the amount added on the third stick
		int x = min(c - a - b + i, l - i);
		B += C(x + 2, 2);
	}

	cout << A - B << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long INT;
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int a,b,c,l;
	cin>>a>>b>>c>>l;
	INT ans=0;
	for(int i=0;i<=l;i++) ans+=1LL*(i+1)*(i+2)/2;
	int t=a-b-c;
	for(int i=0;i<=l;i++){
		int e=t+i;
		if(e<0) continue;
		int yz=l-i;
		e=min(e,yz);
		ans-=1LL*(e+1)*(e+2)/2;
	}
	t=b-a-c;
	for(int i=0;i<=l;i++){
		int e=t+i;
		if(e<0) continue;
		int yz=l-i;
		e=min(e,yz);
		ans-=1LL*(e+1)*(e+2)/2;
	}
	t=c-b-a;
	for(int i=0;i<=l;i++){
		int e=t+i;
		if(e<0) continue;
		int yz=l-i;
		e=min(e,yz);
		ans-=1LL*(e+1)*(e+2)/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

ll calc(int a, int b, int c) {
    if(c < 0) return 0;
    if(a > b) swap(a, b);
    if(c <= a) return 1ll * (c + 1) * (c + 2) / 2;
    ll ans = 1ll * (2 * c - a + 2) * (a + 1) / 2;
    if(b < c) {
        if(c - a < b) ans -= 1ll * (c-b) * (c-b+1) / 2;
        else ans = 1ll * (a+1) * (b+1);
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll ans = 0;
    int a, b, c, l;
    cin >> a >> b >> c >> l;
    int t = a + b + c;
    for(int s = 0; s <= l; s ++) {
        int u = s + t - 2 * a;
        int v = s + t - 2 * b;
        int w = s + t - 2 * c;
        if(u <= 0 || v <= 0 || w <= 0) continue;
        u = (u - 1) / 2;
        v = (v - 1) / 2;
        w = (w - 1) / 2;
        ans += 1ll * calc(u, v, s) - calc(u, v, s-w-1);
    }
    cout << ans << endl;
}

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

typedef long long ll;
const ll MAXL = 6e5;

ll triangle(ll S) {
    if(S < 0) return 0;
    return (S + 2) * (S + 1) / 2;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);

    ll V[3];
    cin >> V[0] >> V[1] >> V[2];;

    ll L;
    cin >> L;

    ll ans = 0;

    for (int H = 0; H <= MAXL; H++) {
        for (int w = 0; w < 3; w++) {
            if(V[w] > H) continue;

            ll R = L - (H - V[w]);
            R = min(R, H + V[w] - V[0] - V[1] - V[2]);
            ans -= triangle(R);
        }
    }

    ans += (L + 1) * (L + 2) * (L + 3) / 6;
    cout << ans << endl;
}

// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ████━████   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━

// Author        : WhyWhy
// Created Time  : 2015年09月07日 星期一 20时31分01秒
// File Name     : A.cpp

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

int a,b,c,l;
long long ans=0;

long long getnum0(int L,int R,int B)
{
	if(R<0) return 0;
	if(L<0) L=0;

	if(B<0)
	{
		if(R<(-B)) return 0;
		if(L<(-B)) L=-B;
	}

	if(R<L) return 0;

	return (L+B+R+B+2LL)*(R-L+1LL)/2;
}

long long getnum1(int L,int R,int B)
{
	if(L>B) return 0;
	if(R>B) R=B;

	if(R<0) return 0;
	if(L<0) L=0;

	if(R<L) return 0;

	return (-L+B-R+B+2LL)*(R-L+1LL)/2;
}

long long count(int D,int N,int M,int Q)
{
	if(M<Q || D<N)
		return 0;

	long long ret=0;
	int x1=ceil((N-M)/2.0),x2,x3=floor((D-Q)/2.0);

	x2=floor((D-M)/2.0);
	ret+=getnum0(x1,x2,M);
	ret+=getnum1(x2+1,x3,D);

	x2=floor((N-Q)/2.0);
	ret-=getnum1(x1,x2,N-1);
	ret-=getnum0(x2+1,x3,Q-1);

	return ret;
}

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	cin>>a>>b>>c>>l;

	for(int i=0;i<=l;++i)
		ans+=count(l-i,a+i-b-c+1,a+i+b-c-1,b-c+1-a-i);

	cout<<ans<<endl;

	return 0;
}

#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
typedef long long l;
l a,b,c;
l n;

int main(){
    ios_base::sync_with_stdio(false);
    #ifdef MiyazonoKaori
        freopen("1.inp","r",stdin);
    #endif // MiyazonoKaori
    l res=0;
    cin>>a>>b>>c>>n;
    for(int i=0;i<=n;++i){
        if((a+i)<(b+c)) continue;
        else{
            l cc=min(i+a-b-c,n-i);
            //cout<<cc<<endl;
            res+=(cc+1)*(cc+2)/2;
        }
    }
    for(int i=0;i<=n;++i){
        if((b+i)<(a+c)) continue;
        else{
            l cc=min(i+b-a-c,n-i);
            res+=(cc+1)*(cc+2)/2;
        }
    }
    for(int i=0;i<=n;++i){
        if((c+i)<(a+b)) continue;
        else{
            l cc=min(i+c-b-a,n-i);
            res+=(cc+1)*(cc+2)/2;
        }
    }
    cout<<(n+1)*(n+2)*(n+3)/6-res;
}

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;

int main()
{
    LL  a, b, c, l;
    cin >> a >> b >> c >> l;
    LL ans = (LL)(l + 3) * (l + 2)/2 * (l + 1)/3;
    for (int i = 0; i <= l; i++) {
        LL a1 = a + i;
        LL t = min(a1 - c - b, l - i);
        if (t < 0) continue;
        ans -=  (t + 2) * (t + 1) / 2;
    }
    for (int i = 0; i <= l; i++) {
        LL b1 = b + i;
        LL t = min(b1 - a - c, l-i);
        if (t < 0) continue;
        ans -= (LL)(t + 2) * (t + 1) / 2;
    }
    for (int i = 0; i <= l; i++) {
        LL c1 = c + i;
        LL t = min(c1 - a - b, l - i);
        if (t < 0) continue;
        ans -= (LL)(t + 2) * (t + 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define siz(a) int(a.size())
#define endl "\n"
//			compile ::   g++ -Wall -std=c++0x -c "%f"
//			build   ::   g++ -Wall -std=c++0x -o "%e" "%f"

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < ll > vll;

const int mod=1e9+7;
const int maxn=1e6+5;

/*	finding inverse upto n
 * for i in xrange(2, N):
    ifc[i] = -(mod / i) * ifc[mod % i] % mod
 *
*/
ll power(ll base, ll exp){ll res = 1; while(exp){if(exp%2)res*=base;base*=base;res%=mod;base%=mod;exp/=2;}return res;}

ll side[3], l, ans;

ll solve(ll a, ll b, ll c, ll la){

	if(a + la < b + c){
		return 0; // ie if a+la is not the longest side then return 0
	}

	//now the two equations will be a+la >= b+lb+c+lc <==> lb+lc <= a-b-c+la and la+lb+lc <= l <==> lb+lc <= l - la
	//so it means la+lb should be min of these two and then no of ways to distribute the length is
	//either to la or lb or to nothing so again 3 boxes and min balls so again it refers to (min+3-1)C(3-1)

	ll ans = min(a-b-c+la, l-la);

	return ((ans+2)*(ans+1))/2;

}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);

	ll i, j;

	for(i=0; i<3; i++)
		cin >> side[i];

	cin >> l;

	ans =  ((l+3)*(l+2)*(l+1))/6;// total no of ways to form the ans is a + la, b + lb, c+lc, left so there are 3 bars to divide total l balls
	// so it is (l+4-1)C(4-1)

	//now as non degenerate triangle is one with longest side > sum of other two sides
	//for this we will consider one by one each side and try to make it longest now to make it longest we will iterate
	//from 0 to l as we can add anything to it and we will see for how many condition does la, lb satify the equatinos

	for(i=0; i<3; i++){
		for(j=0; j<=l; j++){
			ans = ans - solve(side[i], side[(i+1)%3], side[(i+2)%3], j); //subtracting the ans
		}
	}
	cout << ans;
	return 0;
}

// cfr(317)qCsd.cpp: ���������� ����� ����� ��� ����������� ����������.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	long long a, b, c, l;
	cin >> a >> b >> c >> l;
	long long num_vars = (l + 1) * (l + 2) * (l + 3) / 6;
	long long answ = 0;
	long long minim;
	for (long long i = 0; i <= l; i++)
	{
		minim= min(a - b - c + i, l - i);
		if(minim >= 0)
		answ += (minim + 1) * (minim + 2) / 2;
	}
	for (long long i = 0; i <= l; i++)
	{
		minim = min(b - a - c + i, l - i);
		if (minim >= 0)
		answ += (minim + 1) * (minim + 2) / 2;
	}
	for (long long i = 0; i <= l; i++)
	{
		minim = min(c - b - a + i, l - i);
		if (minim >= 0)
		answ += (minim + 1) * (minim + 2) / 2;
	}
	cout << num_vars - answ;
	cin >> a;
	return 0;
}

#include<stdio.h>
int aa(int x)
{
    if(x>0) return x/2;
    else return -((-x)/2+1);
}
long long bio(int x,int y,int z,int k)
{
    if(x+y+z<k) return 0;
    else
    {
        long long ans,a1,a2,a3,b1,b2,b3,c,a;
        if(x+1>k) a1=0LL;
        else a1=(long long)(k-x+1)*(long long)(k-x)/2LL;
        if(y+1>k) a2=0LL;
        else a2=(long long)(k-y+1)*(long long)(k-y)/2LL;
        if(z+1>k) a3=0LL;
        else a3=(long long)(k-z+1)*(long long)(k-z)/2LL;
        if(x+y+2>k) b1=0LL;
        else b1=(long long)(k-x-y)*(long long)(k-x-y-1)/2LL;
        if(z+y+2>k) b2=0LL;
        else b2=(long long)(k-z-y)*(long long)(k-z-y-1)/2LL;
        if(x+z+2>k) b3=0LL;
        else b3=(long long)(k-x-z)*(long long)(k-x-z-1)/2LL;
        if(x+y+z+3>k) c=0LL;
        else c=(long long)(k-x-y-z-1)*(long long)(k-x-y-z-2)/2LL;
        a=(long long)(k+2)*(long long)(k+1)/2LL;
        ans=a-(a1+a2+a3)+(b1+b2+b3)-c;
        return ans;
    }
}
int main()
{
    int a,b,c,l,x,y,z;
    long long ans=0LL;
    scanf("%d%d%d%d",&a,&b,&c,&l);
    for(int i=0;i<=l;i++)
    {
        if((c+b+i-a)%2==0) x=(c+b+i-a)/2-1;
        else x=aa(c+b+i-a);
        if((c+a+i-b)%2==0) y=(c+a+i-b)/2-1;
        else y=aa(c+a+i-b);
        if((a+b+i-c)%2==0) z=(a+b+i-c)/2-1;
        else z=aa(a+b+i-c);
        //printf("%d %d %d\n",x,y,z);
        if(x>=0&&y>=0&&z>=0)
        {
            ans+=bio(x,y,z,i);
        }
        //printf("%d ",ans);
    }
    printf("%I64d",ans);
}

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

long long sumUp(long long a, long long b) {
  return (a + b) * (b - a + 1) / 2;
}
long long sumDown(long long a, long long b) {
  return (a + b) * (a - b + 1) / 2;
}

long long solve(long long Z, long long Y, long long Lb, long long Ub) {
  Ub = min(Ub, Z - Y);
  Lb = max(0ll, Lb);
  if (Lb > Ub) return 0;
  if (Y > Z) return 0;
  long long t1 = -Y;
  long long t2 = Z;
  assert(t1 + 1 >= 0 and t2 + 1 >= 0);
  long long ans = 0;
  ++Ub;
  t2 = max(Lb, min(Ub, t2));
  t1 = max(Lb, min(Ub, t1));
  /*
  for (long long t = Lb; t < Ub; ++t) {
    ans += (t > t2 ? Z : t) - (t > t1 ? Y + t : 0) + 1;
  }
  return ans;
  */
  if (t1 < t2) {
    ans += sumUp(Lb + 1, t1);
    ans += (-Y + 1) * (t2 - t1);
    ans += sumDown(Z - Y - t2 + 1, Z - Y - Ub + 2);
  }
  else {
    ans += sumUp(Lb + 1, t2);
    ans += (Z + 1) * (t1 - t2);
    ans += sumDown(Z - Y - t1 + 1, Z - Y - Ub + 2);
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  long long a[3], L; cin >> a[0] >> a[1] >> a[2] >> L;
  long long ans = 0;
  for (int _ = 0; _ < 3; ++_) {
    rotate(a, a + 1, a + 3);
    for (int l = 0; l <= L; ++l) {
      if (a[0] + l <= max(a[1], a[2])) continue;
      long long X = a[0] + l - a[1] - a[2] + 1;
      long long Y = a[2] - a[0] - l + 1;
      long long Z = a[0] + l - 1 - a[1];
      ans += solve(Z, Y, X, L - l);
    }
  }

  for (int _ = 0; _ < 3; ++_) {
    rotate(a, a + 1, a + 3);
    for (int l = a[2] + 1; l < 1e6; ++l) {
      if (a[0] > l or a[1] > l) continue;
      long long left = L - (l - a[0]) - (l - a[1]);
      if (left < 0) continue;
      ans += min(left + 1, l - a[2]);
    }
  }

  for (int l = *max_element(a, a + 3); l < 1e6; ++l) {
    long long left = L - (l - a[0]) - (l - a[1]) - (l - a[2]);
    if (left < 0) continue;
    ++ans;
  }
  cout << ans << '\n';
}

#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (63 - __builtin_clzll(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

template <typename T1, typename T2> inline void remax(T1& a, T2 b) { a = max(a, (T1)b);	}

const int maxN = 1 << 19;

long long f(int a, int b, int c, int l)
{
	int x = a - b - c;
	long long ret = 0;
	FOR(s, 0, l+1)
	{
		long long la = (l-s) - max(0, s-x) + 1;
		la = max(la, 0ll);
		ret += la * (s+1);
	}
	return ret;
}

long long npo3(long long n)
{	return n * (n-1) * (n-2) / 6;	}

void solve()
{
	int t[4];
	FOR(i, 0, 4)
		scanf ("%d", t+i);
	long long res = f(t[0], t[1], t[2], t[3]);
	res += f(t[1], t[0], t[2], t[3]);
	res += f(t[2], t[0], t[1], t[3]);

	res = npo3(t[3]+3) - res;

	printf("%lld\n", res);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}

#include <bits/stdc++.h>
#define int long long

using namespace std;

const int mod = 1e9 + 7;

int C(int n, int k) {
  int ret = 1;
  for(int i = n; i > n - k; --i) {
    ret *= i;
  }
  for(int i = 1; i <= k; ++i) {
    ret /= i;
  }
  return ret;
}

main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int sum = 0;

  int d;
  vector < int > vec(3);
  for(auto &x : vec) cin >> x, sum += x;
  cin >> d;

  int all = C(d + 3, 3);

  for(int i = 0; i < 3; ++i) {
    for(int v = 0; v <= d; ++v) {
      int lim = vec[i] + v;
      if(sum - vec[i] > lim) continue;
      int rem = min(d - v, lim - (sum - vec[i]));
      all -= C(rem + 2, 2);
    }
  }

  cout << all;

  return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<math.h>
#define gc	getchar_unlocked
using namespace std;
long long solve(long long a,long long  b,long long  c,long long r)
{
	int bound=min(a-b-c,r);
	if(bound<0)
		return 0;
	return (long long)(bound+1)*(bound+2)/2;
}
int main()
{
	long long  a,b,c,l;
	cin>>a>>b>>c>>l;
	long long ans=(l+1)*(l+2)*(l+3);
	ans/=6;
	for(long long  i=0;i<=l;i++)
		ans-=solve(a+i,b,c,l-i)+solve(b+i,c,a,l-i)+solve(c+i,a,b,l-i);
	cout<<ans<<"\n";
	return 0;
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
#define test freopen("1.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
int main()
{
    int a,b,c,l;
    cin>>a>>b>>c>>l;
    ll sum=0;
    for(int la=0;la<=l;la++)
    {
        if(a+la-b-c>=0)
        {
            ll x=min(a+la-b-c,l-la);
            sum+=(x+1)*(x+2)/2;
        }
    }
    for(int lb=0;lb<=l;lb++)
    {
        if(b+lb-a-c>=0)
        {ll x=min(b+lb-a-c,l-lb);
        sum+=(x+1)*(x+2)/2;}
    }
    for(int lc=0;lc<=l;lc++)
    {
        if(c+lc-b-a>=0)
        {ll x=min(c+lc-a-b,l-lc);
        sum+=(x+1)*(x+2)/2;
        }
    }
    ll ans=1LL*(l+1)*(l+2)*(l+3)/6;
    cout<<ans-sum<<endl;
    return 0;
}

/*
ID: hepic
PROG: lamps
LANG: C++11
*/
#include<bits/stdc++.h>

#define FOR(i, a, b) for(auto i=a; i!=b+1-2*(a>b); i+=1-2*(a>b))
#define REP(i, a, b) for(auto i=a-(a>b); i!=b-(a>b); i+=1-2*(a>b))
#define ALL(v) v.begin(),v.end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a, b) emplace_back(a, b)
#define fir first
#define sec second
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define SIZE 100010
#define MAXN 1000000007
#define NUM 100000
#define PI acos(-1)
#define open_read1 freopen("C:\\Users\\Hepic\\Desktop\\a.txt","r",stdin)
#define open_write1 freopen("C:\\Users\\Hepic\\Desktop\\b.txt","w",stdout)
#define open_read freopen("cruise.in","r",stdin)
#define open_write freopen("cruise.out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<int, PII> PIPII;
typedef pair<PII, PII> PPIIPII;
typedef pair<LL, LL> PLL;
typedef pair<LL, PLL> PLPLL;

template<typename T, typename T1>
ostream& operator << (ostream &out, pair<T, T1> obj)
{
    return out<<"("<<obj.first<<","<<obj.second<<")";
}

template<typename T, typename T1>
ostream& operator << (ostream &out, map<T, T1> cont)
{
    typename map<T, T1>::const_iterator itr = cont.begin();
    typename map<T, T1>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;
}

template<typename T>
ostream& operator << (ostream &out, set<T> cont)
{
    typename set<T>::const_iterator itr = cont.begin();
    typename set<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;
}

template<typename T, template<typename ELEM, typename ALLOC=allocator<ELEM>> class CONT>
ostream& operator << (ostream &out, CONT<T> cont)
{
    typename CONT<T>::const_iterator itr = cont.begin();
    typename CONT<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;
}

template<typename T>
T gcd(T a, T b)
{
    T min_v = min(a, b);
    T max_v = max(a, b);

    while(min_v)
    {
        T temp = max_v % min_v;
        max_v = min_v;
        min_v = temp;
    }

    return max_v;
}

template<typename T>
T lcm(T a, T b)
{
    return (a*b) / gcd(a, b);
}

/*#################################################################################################################
#################################################################################################################
#################################################################################################################
#################################################################################################################*/

int A, B, C, L;
LL total, wrong, correct;

LL ret_wrong(LL a, LL b, LL c, LL l)
{
    LL ret = 0, rem = 0;

    if(a < b+c)
        rem = b + c - a;

    if(rem > L)
        return 0;

    a += rem;
    l -= rem;

    FOR(addA, 0, l)
    {
        rem = min(a + addA - b - c,  l - addA);
        ret += (rem+2)*(rem+1) / 2;
    }

    return ret;
}

int main()
{
    scanf("%d%d%d%d", &A, &B, &C, &L);

    total = (LL)(L+3)*(LL)(L+2)*(LL)(L+1) / 6LL;

    wrong += ret_wrong(A, B, C, L);
    wrong += ret_wrong(B, A, C, L);
    wrong += ret_wrong(C, A, B, L);

    correct = total - wrong;

    printf("%I64d\n", correct);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll count(int a,int b,int c,int d){
    ll ret =0 ;
    for(int i = 0;i<=d;i++){
        if(a+i<b+c) continue;
        int t  = min(a-b-c+i,d-i);
        ret += ll(t+1)*(t+2)/2;
    }
    return ret;
}
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    ll tot = ll(d+1)*(d+2)*(d+3)/6;
    tot -= count(a,b,c,d);
    tot -= count(b,a,c,d);
    tot -= count(c,a,b,d);
    cout<<tot<<endl;
}

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
typedef long long LL;
LL tre(LL x)
{
    return x*(x+1)>>1;
}
LL count(int a,int ab,int ac,int b,int c,int t)
{
    int x=ab-b+1,y=ac-c+1;
    if(x<=0||y<=0)return 0;
    if(a+b+c>t)return 0;
    LL ans=(LL)x*y;
    if(a+ab+ac>t)
    {
        int s=a+ab+ac-t;
        ans-=tre(s);
        if(x<s)ans+=tre(s-x);
        if(y<s)ans+=tre(s-y);
    }
    if(b+c<=a)ans-=tre(a-b-c+1);
    return ans;
}

int main()
{
    int a,b,c,d,t,s;
    LL ans=0;
    scanf("%d%d%d%d",&a,&b,&c,&t);
    t+=a+b+c;
    for(int i=a;i*2<t;++i)
    {
        ans+=count(i,i,i,b,c,t);
    }
    for(int i=b;i*2<t;++i)
    {
        ans+=count(i,i-1,i,a,c,t);
    }
    for(int i=c;i*2<t;++i)
    {
        ans+=count(i,i-1,i-1,a,b,t);
    }
    printf("%I64d\n",ans);
    return 0;
}

#include <stdio.h>

long long int func(long long int s, long long int t, long long int left)
{
	if(s>left&&t>left) return (left+1)*(left+2)/2;
	else if(s>left)
	{
		//left + ... + left-t
		return (left+1)*(t+1) -t*(t+1)/2;
	}
	else if(t>left)
	{
		return (left+1)*(s+1) - s*(s+1)/2;
	}
	else
	{
		if(t+s<=left) return (t+1)*(s+1);
		else
		{
			long long int k = s+t-left;
			return (t+1)*(s+1) - k*(k+1)/2;
		}
	}
}
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int max = a>b?a>c?a:c:b>c?b:c;
	long long int ans = 0;
	for(int i=max;i<=max+d;i++)
	{
		int left = d-(i-a);
		if(left>=0)
		{
			ans += func(i-b,i-c,left);
			int left2 = i-b-c;
			if(left2>=0) ans -= func(i-b,i-c,left2<left?left2:left);
		}
		left = d-(i-b);
		if(left>=0)
		{
			ans += func(i-a,i-c,left);
			int left2 = i-a-c;
			if(left2>=0) ans -= func(i-a,i-c,left2<left?left2:left);
		}
		left = d-(i-c);
		if(left>=0)
		{
			ans += func(i-a,i-b,left);
			int left2 = i-a-b;
			if(left2>=0) ans -= func(i-a,i-b,left2<left?left2:left);
		}
		left = d - (i-a) - (i-b);
		if(left>=0) ans -= func(i-c,0,left);
		left = d - (i-a) - (i-c);
		if(left>=0) ans -= func(i-b,0,left);
		left = d - (i-b) - (i-c);
		if(left>=0) ans -= func(i-a,0,left);
		left = d- (i-a) - (i-b) - (i-c);
		if(left>=0) ans += func(0,0,left);
		//printf("%d : %lld!!\n",i,ans);
	}
	printf("%lld",ans);
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define mp make_pair
#define hell 998244353
#define F first
#define S second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll a , b , c , l , ans = 0 ;
    cin >> a >> b >> c >> l ;
    rep( i , 0 , l + 1 ){
        ll d1 = min( l - i , a + i - b - c ) , d2 = min( l - i , b + i - a - c ) , d3 = min( l - i , c + i - a - b ) ;
        if( d1 >= 0 )
            ans += ((d1+2)*(d1+1)) / 2 ;
        if( d2 >= 0 )
            ans += ((d2+2)*(d2+1)) / 2 ;
        if( d3 >= 0 )
            ans += ((d3+2)*(d3+1)) / 2 ;
    }
    cout << ((l+1)*(l+2)*(l+3))/6 - ans ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
using namespace std;

#define nln        puts("")                         ///printnewline
#define getint(a)  scanf("%d",&a);
#define max3(a,b,c) max(a,max(b,c))                  ///3 ta theke max
#define min3(a,b,c) min(a,min(b,c))                  ///3 ta theke min

#define FOR1(i,n)  for(int i=1;i<=n;i++)
#define FOR0(i,n)  for(int i=0;i<n;i++)                 ///looping
#define FORR(i,n)  for(int i=n-1;i>=0;i--)
#define ALL(p)     p.begin(),p.end()

#define SET(p)     memset(p,-1,sizeof(p))
#define CLR(p)     memset(p,0,sizeof(p))            ///memset
#define MEM(p,v)   memset(p,v,sizeof(p))

#define READ(f)    freopen(f, "r", stdin)           /// file
#define WRITE(f)   freopen(f, "w", stdout)

#define SZ(c)      (int)c.size()
#define PB(x)      push_back(x)                     ///STL defines
#define MP(x,y)    make_pair(x,y)
#define ff         first
#define ss         second

#define LI         long int
#define LLI        long long int
#define f64        long double
#define PI         acos(-1.0)                        ///PI er value

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N= N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}
void CI(int &_x)
{
    scanf("%d",&_x);
}

void CO(int &_x)
{
    cout<<_x;
}

template<typename T> void getarray(T a[],int n)
{
    for(int i=0; i<n; i++) cin>>a[i];
}
template<typename T> void printarray(T a[],int n)
{
    for(int i=0; i<n-1; i++) cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
}

const double EPS=1e-9;                              ///constatnts
const int INF=0x7f7f7f7f;

int dr8[8]= {1,-1,0,0,1,-1,-1,1};            ///8 direction move
int dc8[8]= {0,0,-1,1,1,1,-1,-1};
int dr4[4]= {0,0,1,-1};                      ///4 direction move
int dc4[4]= {-1,1,0,0};                      ///or adjacent dir.
int kn8r[8]= {1,2,2,1,-1,-2,-2,-1};          ///knight moves
int kn8c[8]= {2,1,-1,-2,-2,-1,1,2};
LLI func(LLI a,LLI b,LLI c,LLI l)
{
    LLI ans=0;
    for(int i=0; i<=l; i++)
    {

        LLI t_a=a+i;
       if(b+c>t_a)continue;

       LLI need=min(l-i,t_a-c-b);
     //  cout<<i<<" "<<need<<"\n";
       ans+=((need+2)*(need+1))/2;

    }
//    cout<<"PP "<<ans<<"\n";
return ans;
}

int main()
{

    LLI a,b,c,l;
    cin>>a>>b>>c>>l;
    LLI total=((l+3)*(l+2)*(l+1))/6;

   // cout<<"FF : "<<total<<"\n";
total-=func(a,b,c,l);
total-=func(b,a,c,l);
total-=func(c,a,b,l);
cout<<total<<"\n";

}

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

using ll = long long;

int main() {
    ll a, b, c, l; cin >> a >> b >> c >> l;

    auto calc = [l] (ll a, ll b, ll c, ll z) {
        const ll m = min(l - z, c + z - a - b);
        if(m < 0) return 0LL;
        return (m + 2) * (m + 1) / 2;
    };
    ll ans = (l + 3) * (l + 2) * (l + 1) / 6;
    for(ll z = 0; z <= l; ++z) {
        ans -= calc(a, b, c, z) + calc(b, c, a, z) + calc(c, a, b, z);
    }

    cout << ans << endl;
}

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

typedef long long ll;

ll eval(ll a, ll b, ll c, ll x) {
	ll cur=min(x,a-(b+c));
	return (cur+1)*(cur+2)/2;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll a,b,c,l,ret; cin>>a>>b>>c>>l;
	ret=(l+1)*(l+2)*(l+3)/6;
	for (int y=0; y<=l; y++)
		ret-=eval(a+y,b,c,l-y),
		ret-=eval(b+y,c,a,l-y),
		ret-=eval(c+y,a,b,l-y);
	cout << ret << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef vector <int> vi;

#define rep(i, n) for(int i = 0; i < (n); ++i)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define mset(a, v) memset(a, v, sizeof(a))
#define sz(a) ((int)a.size())

#define dbn cerr << "\n"
#define dbg(x) cerr << #x << " : " << (x) << " "
#define dbs(x) cerr << (x) << " "

long long sum(int n) {
    return (long long)n * (n + 1) / 2;
}

long long sumAP(long long a, long long n, long long d) {
    long long ret = n * (a + a + (n - 1) * d);
    return ret / 2;
}

// (x, y) 0 <= x <= a, 0 <= y <= b 0 <= (x + y) <= x
long long get(int a, int b, int x) {
    if (x < 0)
        return 0;
    if (x > a + b)
        return 0;
    if (a > b)
        swap(a, b);
    if (x <= a)
        return sum(x + 1);
    else if (x <= b)
        return sum(a + 1) + (long long)(x - a) * (a + 1);
    else
        return sum(a + 1) + (long long)(b - a) * (a + 1) + sumAP(a, x - b, -1);
}

// (x, y) 0 <= x <= a, 0 <= y <= b l < (x + y) <= r
long long get(int a, int b, int l, int r) {
    // cerr << "get() : a " << a << " b " << b << " l " << l << " r " << r << "\n";
    // cerr << get(a, b, r) << " " << get(a, b, l) << "\n";
    return get(a, b, r) - get(a, b, l);
}

long long calc(int a, int b, int c, int len) {
    long long ways = 0;
    for (int x = a; x <= a + len; ++x) {
        if (b > x or c > x)
            continue;
        int l = x - (b + c);
        int r = min(len - (x - a), (x - b) + (x - c));
        if (l <= r) {
            ways += get(x - b, x - c, l, r);
            // cerr << "x : " << x << " l " << l << " r " << r << " " << ways << "\n";
        }
    }
    return ways;
}

int brute(int a, int b, int c, int len) {
    int ans = 0;
    for (int da = 0; da <= len; ++da) {
        for (int db = 0; da + db <= len; ++db) {
            for (int dc = 0; da + db + dc <= len; ++dc) {
                int aa = a + da;
                int bb = b + db;
                int cc = c + dc;
                int sum = aa + bb + cc;
                int mx = max(aa, max(bb, cc));
                if (mx < sum - mx) {
                    cerr << "valid " << aa << " " << bb << " " << cc << "\n";
                    ++ans;
                }
            }
        }
    }
    return ans;
}

const int N = (int)5;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(NULL));
    int a, b, c, len;
    cin >> a >> b >> c >> len;
    // a = 1 + rand() % N;
    // b = 1 + rand() % N;
    // c = 1 + rand() % N;
    // len = 0 + rand() % N;
    // a = 1, b = 1, c = 1, len = 3;

    long long ways = 0;
    ways += calc(a, b, c, len);
    // cerr << "A " << ways << "\n";
    ways += calc(b, a, c, len);
    // cerr << "B " << ways << "\n";
    ways += calc(c, a, b, len);
    // cerr << "C " << ways << "\n";

    int mx = max(a, max(b, c));
    int mn = min(a, min(b, c));
    for (int x = mx; x <= mx + len; ++x) {
        if ((x - a) + (x - b) + (x - c) <= len)
            ways += 1;

        // cerr << "x : " << x << " " << ways << "\n";

        // a = x, b = x,
        if ((x - a) + (x - b) <= len) {
            int rem = len - (x - a) - (x - b);
            int l = max(1, c);
            int r = min(2 * x - 1, c + rem);
            if (l <= r) {
                ways -= r - l + 1;
            }
        }
        // cerr << "ab x : " << x << " " << ways << "\n";

        // a = x, c = x,
        if ((x - a) + (x - c) <= len) {
            int rem = len - (x - a) - (x - c);
            int l = max(1, b);
            int r = min(2 * x - 1, b + rem);
            if (l <= r) {
                ways -= r - l + 1;
            }
        }
        // cerr << "ac x : " << x << " " << ways << "\n";

        // b = x, c = x,
        if ((x - b) + (x - c) <= len) {
            int rem = len - (x - b) - (x - c);
            int l = max(1, a);
            int r = min(2 * x - 1, a + rem);
            if (l <= r) {
                ways -= r - l + 1;
            }
        }

        // cerr << "bc x : " << x << " " << ways << "\n";
    }

    // assert(ways >= 0);
    cout << ways << "\n";

    // int chk = brute(a, b, c, len);
    // if (ways != chk) {
    //     cerr << a << " " << b << " " << c << " " << len << "\n";
    //     cerr << ways << " " << chk << "\n";
    //     assert(false);
    // }
    return 0;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

long long a, b, c, l;
long long ans = 0;
int main() {
    cin >> a >> b >> c >> l;
    for (int i = 0; i <= l; i++) {
        long long peri = a + b + c + i;
        long long nways = ((i + 2) * (i + 1)) / 2;
        long long nbadways = 0;
        long long half = (peri + 1) / 2;
        // if a breaks it
        long long a_uses = max(0LL, half - a);
        long long l_remaining = max(-1LL, i - a_uses);
        nbadways += (((l_remaining + 1) * (l_remaining + 2)) / 2);

        long long b_uses = max(0LL, half - b);
        l_remaining = max(-1LL, i - b_uses);
        nbadways += (((l_remaining + 1) * (l_remaining + 2)) / 2);

        long long c_uses = max(0LL, half - c);
        l_remaining = max(-1LL, i - c_uses);
        nbadways += (((l_remaining + 1) * (l_remaining + 2)) / 2);

        // cout << "\nnways: " << nways << ", nbadways: " << nbadways;

        ans += nways - nbadways;
    }

    cout << ans;
}

//
//  main.cpp
//  A
//
//  Created by nicomazz on 24/06/15.
//  Copyright (c) 2015 nicomazz. All rights reserved.
//

#include <cstdlib>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <queue>
#include <deque>
#include <vector>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <bitset>

using namespace std;

#define TEST
#define MAXN 100010

typedef pair<int, int> pi;
typedef pair<int,pi> pii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef  long long ll;

#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

#define iOS ios_base::sync_with_stdio(false)
#define error(x) cerr << #x << " = " << (x) <<endl
#define all(x) (x).begin(), (x).end()
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}

#define gc getchar
inline void scanInt(int &x)
{
    register char c=gc();
    x = 0;
    bool neg = false;
    while( c<48 || c>57) {if (c == '-')neg = true; c=gc();}
    for(;c>47 && c<58;c = gc()){x = (x<<1) + (x<<3) + c - 48;}
    if (neg) x*=-1;
}

bool triangle(int _a, int _b, int _c)
{
    return _a < _c+_b && _c < _a+_b && _b < _c+_a;
}

ll to_Remove(int a,int b, int c, int l)
{
    if ( a < b+c)
        return 0;

    ll to_add = min( a-b-c, l);

    return (to_add+1)*(to_add+2) / 2;
}

int main(int argc, const char * argv[])
{
#ifndef TEST
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int a,b,c,l;

    cin>>a>>b>>c>>l;

    ll ways = (l+1)*(l+2)*(l+3) / 6;

    for (int i = 0; i <= l; i++)
    {
        ways-= to_Remove(a+i, b, c, l-i);
        ways-= to_Remove(b+i, a, c, l-i);
        ways-= to_Remove(c+i, b, a, l-i);
    }

    cout<<ways;

    return 0;
}

//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int a, b, c, l;
LL ans = 0;

int main()
{
    cin>>a>>b>>c>>l;
    For(i,0,l+1)
        ans+=(l-i+1)*(l-i+2)/2;
    //cout<<ans<<endl;
    For(i,max(0,b+c-a),l+1)
    {
        LL q=min(l-i,a+i-b-c)+1;
        ans-=q*(q+1)/2;
    }
    swap(a,b);
    For(i,max(0,b+c-a),l+1)
    {
        LL q=min(l-i,a+i-b-c)+1;
        ans-=q*(q+1)/2;
    }
    swap(a,c);
    For(i,max(0,b+c-a),l+1)
    {
        LL q=min(l-i,a+i-b-c)+1;
        ans-=q*(q+1)/2;
    }
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MAXN ll(1e5)
#define INF  ll(1e17)
typedef long long ll;

ll sum[111111], ZOM[1111111];

inline int get(ll a, ll b, ll c, ll l){
    ll x, ans = 0, F = b+c-a;
    if (a < c+b)
        a+=F, l-=F;

    x = a-b-c;

    if (a == b+c)
        ans += 2*ZOM[(l+2)/2];
    else
        ans += 2*ZOM[(l-x+2)/2]-ZOM[x+1];
    if(l%2==0) ans-=sum[(l-x)/2+1];
    return ans;
}

ll a, b, c, l;
main () {
    cin >> a >> b >> c >> l;
    if (a+b+c+l <= max(a, max(b, c))*2){
        cout << 0;
        return 0;
    }

    for (ll i = 1; i <= l+1; ++i){
        sum[i] += sum[i-1]+i;
        ZOM[i] += sum[i]+ZOM[i-1];
    }
    ll ans = get(a, b, c, l)+get(b, a, c, l)+get(c, b, a, l);
    cout << ZOM[l+1]-ans;
}

// 571A
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int a, b, c, l;
  cin >> a >> b >> c >> l;
  long long num_partitions_of_l = (l + 3) * (l + 2) * (l + 1) / 6;
  long long num_invalid_ways = 0;
  for (int da = 0; da <= l; da++) {
    // Configurations can be invalid in three mutually exclusive ways:
    // (1) a + da >= b + db + c + dc => db + dc <= a + da - b - c
    // (2) b + db >= a + da + c + dc => db - dc >= a + da - b + c
    // (3) c + dc >= a + da + b + db => dc - db >= a + da + b - c
    // Also, db + dc <= l - da. Assume that a + da is the longest side length.
    // For each value of db + dc, there are db + dc + 1 ways to partition db +
    // dc as an integer sum. Thus, the number of invalid configurations of type
    // (1) is
    //   1 + 2 + ... + (x + 1) = (x + 1)(x + 2) / 2
    // where x = min{max(a + da - b - c, 0), l - da}.
    if (a + da >= b + c) {
      int x = min(a + da - b - c, l - da);
      num_invalid_ways += (long long) (x + 1) * (x + 2) / 2;
    }
    /*
    // Proceeding using similar reasoning, the number of type (2) is
    //   1 + 2 + ... + (y + 1) = (y + 1)(y + 2) / 2
    // if y = l - (a + da - b + c) >= 0, and 0 otherwise.
    int y = l - (a + da - b + c);
    if (y >= 0) {
      num_invalid_ways += (long long) (y + 1) * (y + 2) / 2;
    }
    // Type (3) is symmetrical to type (2).
    int z = l - (a + da + b - c);
    if (z >= 0) {
      num_invalid_ways += (long long) (z + 1) * (z + 2) / 2;
    }
    */
  }
  // Repeat the above reasoning for the remaining two cases.
  for (int db = 0; db <= l; db++) {
    if (b + db >= a + c) {
      int y = min(b + db - a - c, l - db);
      num_invalid_ways += (long long) (y + 1) * (y + 2) / 2;
    }
  }
  for (int dc = 0; dc <= l; dc++) {
    if (c + dc >= a + b) {
      int z = min(c + dc - a - b, l - dc);
      num_invalid_ways += (long long) (z + 1) * (z + 2) / 2;
    }
  }
  cout << num_partitions_of_l - num_invalid_ways << '\n';
}

#include<bits/stdc++.h>
using namespace std;
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define MC(n,m) memcpy((n),(m),sizeof(n))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define FOR(x,y) for(__typeof(y.begin())x=y.begin();x!=y.end();x++)
#define ALL(x) x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#ifdef ONLINE_JUDGE
#define FILEIO(name) \
  freopen(name".in", "r", stdin); \
  freopen(name".out", "w", stdout);
#else
#define FILEIO(name)
#endif

#define _TOKEN_CAT2(x, y) x ## y
#define _TOKEN_CAT(x, y) _TOKEN_CAT2(x, y)
#define _MACRO_OVERL3(_1, _2, _3, _N, ...) _N
#define _RANGE1(a) int _TOKEN_CAT(_t, __LINE__)=0; _TOKEN_CAT(_t, __LINE__)<(a); (_TOKEN_CAT(_t, __LINE__))++
#define _RANGE2(i, a) int (i)=0; (i)<(a); (i)++
#define _RANGE3(i, a, b) int (i)=a; (i)<(b); (i)++
#define range(...) _MACRO_OVERL3(__VA_ARGS__, _RANGE3, _RANGE2, _RANGE1)(__VA_ARGS__)
typedef long long i64;

int main() {
    int A, B, C, L;
    cin >> A >>  B >> C >> L;

    function<i64(i64,i64,i64)> f = [&](i64 a, i64 b, i64 c) {
        if (a < 0 or b < 0) return 0LL;
        if (c < 0) return a*b;
        if (a < b) return f(b, a, c);
        if (a+b < c) return 0LL;
        if (a >= c and b >= c) return (a+1)*(b+1) - (c*(c+1))/2;
        if (a >= c)  return (a+1)*(b+1) - (c+c-b)*(b+1)/2;
        return (a+b-c+1)*(a+b-c+2)/2;
    };

    i64 ans = 0;

    for (int i=0; i<=L; i++) {
        int lf = L-i;
        int c = max(A+i-B-C+1, 0);
        if (lf >= c) {
            ans += f(A+i-B, A+i-C, c)-f(A+i-B, A+i-C, lf+1);
            //cout << "1 = " << f(A+i-B, A+i-C, c)-f(A+i-B, A+i-C, lf+1) << endl;
        }

        c = max(B+i-C-A+1, 0);
        if (lf >= c) {
            ans += f(B+i-C, B+i-A-1, c)-f(B+i-C, B+i-A-1, lf+1);
            //cout << "2 = " << f(B+i-C, B+i-A-1, c)-f(B+i-C, B+i-A-1, lf+1) << endl;
        }

        c = max(C+i-B-A+1, 0);
        if (lf >= c)
            ans += f(C+i-B-1, C+i-A-1, c) - f(C+i-B-1, C+i-A-1, c);

        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

// ntuj - edgcxw28031p76kb02jv0

#pragma comment(linker,"/stack:67108864")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <climits>
#include <cfloat>
#include <functional>
#include <ctime>
#include <numeric>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <utility>
#include <bitset>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <typeinfo>
#include <cassert>
#include <ctime>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forn1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = int(n); i > 0; --i)
#define foran(i, a, n) for(int i = int(a); i <= int(n); ++i)

#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define all(v) (v).begin(),(v).end()

typedef long double ld;
typedef long long ll;

const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
const ll INF = 1000 * 1000 * 1000 + 9;
const int NMAX = 1000*1000 + 3;

int a, b, c, l;

inline bool read()
{
    if (!(cin >>a >>b >>c >>l))
        return false;
    return true;
}

ll calc(int a, int b, int len)
{
    ll ans = 0;
    if (len == 0)
        return 1;
    if (len <= a && len <= b)
        ans = (len * (len + 1)) / 2;
    else
    {
        ans = (a + 1) * (b + 1);
        ans -= (max(a, b) * (len - min(a, b)))/2;
    }
    return ans;
}

ll calc(int a, int b, int c, int l)
{
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        if (b + c + l - i <= newa) continue;
        int addmin = max(0, newa - b - c + 1);
        int addmax = l - i;
        int mlb = newa - b - 1;
        int mlc = newa - c - 1;
        if (mlb < 0 || mlc < 0) continue;
        if (mlb + mlc < addmin) continue;
        ans += calc(mlb, mlc, addmax) - calc(mlb, mlc, addmin - 1);
        //cerr <<mlb <<' ' <<mlc <<' ' <<addmax <<endl;//calc(mlb, mlc, addmax) <<endl;
    }
    return ans;

}

ll calc1(int a, int b, int c, int l)
{
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        int newb = newa;

        if (newb < b) continue;
        int addmin = i + (newb - b) ;
        if (addmin > l) continue;
        if (newa <= c) continue;
        ans += min(l - addmin + 1, newa - c);
    }
    return ans;
}

ll calc2(int a, int b, int c, int l)
{
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        int newb = newa;
        int newc = newa;

        if (newb < b) continue;
        if (newc < c) continue;
        int addmin = i + (newb - b) + (newc - c) ;
        if (addmin > l) continue;
        ans ++;
    }
    return ans;
}

inline void solve()
{
    ll ans = 0;
    ans += calc(a, b, c, l);
    ans += calc(b, a, c, l);
    ans += calc(c, a, b, l);
    ans += calc1(a, b, c, l);
    ans += calc1(a, c, b, l);
    ans += calc1(b, c, a, l);
    ans += calc2(a, b, c, l);
    cout <<ans <<endl;
}

int main()
{
    ifstream ifile("input.txt");
    if (ifile) {
        freopen("input.txt", "rt", stdin);
    }
#ifdef ONLINE_JUDGE
    if (ifile) {
        freopen("output.txt","wt",stdout);
    }
#endif
    while(read())
        solve();
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXM=25;
const long long MOD=1000000007;

long long handle(int a,int b,int c,int l)
{
    if (a<b+c) return 0LL;
    long long ans=min(a-b-c,l);
    return (ans+1)*(ans+2)/2;
}

int a,b,c,l;
long long sum[301000];

int main()
{
    while(scanf("%d%d%d%d",&a,&b,&c,&l)!=EOF)
    {
        sum[0]=1;
        for (int i=1;i<=l;i++)
            sum[i]=sum[i-1]+(i+1)*(i+2)/2;
        long long ans=sum[l];
        for (int i=0;i<=l;i++)
        {
            ans=ans-handle(a+i,b,c,l-i);
            ans=ans-handle(b+i,a,c,l-i);
            ans=ans-handle(c+i,a,b,l-i);
        }
        cout<<ans<<endl;
    }
    return 0;
}

#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#define ll long long int
#define pb push_back
#define ld long double
#define sz size
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<ll, int>
#define F first
#define S second
#define mp make_pair
using namespace std;
ll a[3];
ll L;
ll ans = 0;
ll c[4][300100];
int main() {
	for (int i = 0; i < 3; i++) cin >> a[i];
	cin >> L;
	c[0][0] = 1;
	for (int i = 0; i <= 3; i++) {
		for (int j = 0; j <= (int)(3e5+10); j++) {
			if (i - 1 >= 0 && j - 1 >= 0) c[i][j] += c[i - 1][j - 1];
			if (j - 1 >= 0) c[i][j] += c[i][j - 1];
		}
	}
	ans = c[3][L + 3];
	for (int i = 0; i < 3; i++) {
		for (int l = 0; l <= L; l++) {
			ll x = min(a[i]-a[(i+1)%3]-a[(i+2)%3]+l, L-l);
			ans -= c[2][x+2];
		}
	}
	cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int l;
vector<int> v;

ll one(int maxx, int idx1, int idx2, int idx3) {
	int price = maxx - v[idx1];
	if(price > l) {
		return 0;
	}
	int sum = v[idx2] + v[idx3];
	int target = maxx + 1;
	int at_least = target - sum;
	int has = l - price;
	has = min(has, (maxx - 1 - v[idx2]) + (maxx - 1 - v[idx3]));
	if(at_least > has) {
		return 0;
	}
	int m1 = maxx - 1 - v[idx2];
	int m2 = maxx - 1 - v[idx3];
	ll ans = 1LL * (m1 + 1) * (m2 + 1) - (1LL * (at_least) * (at_least + 1)) / 2;
	int careless_sum = (maxx - 1 - v[idx2]) + (maxx - 1 - v[idx3]);
	int careless_diff = careless_sum - has;
	ans -= (1LL * careless_diff * (careless_diff + 1)) / 2;
	return ans;
}

int two(int maxx, int idx1, int idx2, int idx3) {
	int need = maxx - v[idx1] + maxx - v[idx2];
	if(need > l) {
		return 0;
	}
	int has = l - need;
	has = min(has, maxx - 1 - v[idx3]);
	return has + 1;
}

int main() {
	ios_base::sync_with_stdio(false);

	v.resize(3);
	cin >> v[0] >> v[1] >> v[2] >> l;

	sort(v.begin(), v.end(), greater<int>());

	int maxx = v[0] + l;
	ll ans = 0;
	ford(i, maxx, v[0]) {
		fori(j, 0, 3) {
			int k = j == 0 ? 1 : (j == 1 ? 2 : 0);
			int f = j == 0 ? 2 : (j == 1 ? 0 : 1);
			ans += one(i, j, k, f);
		}
		fori(j, 0, 3) {
			fori(k, j + 1, 3) {
				if(j != k) {
					ans += two(i, j, k, j ^ k ^ 3);
				}
			}
		}
		if((i - v[0]) + (i - v[1]) + (i - v[2]) <= l) {
			ans++;
		}
	}
	cout << ans << '\n';

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long i,i0,n,m,a,b,c,l,pre[300005];
int main()
{
    scanf("%lld %lld %lld %lld",&a,&b,&c,&l);
    pre[0]=1;
    for(i=1;i<=l;i++)pre[i]=pre[i-1]+i+1;
    for(i=0;i<=l;i++)m+=(i+1)*i/2+i+1;
    printf("%lld\n",m);
    for(i=max(0ll,b+c-a);i<=l;i++)m-=pre[min(a+i-b-c,l-i)],printf("%lld--\n",min(a+i-b-c,l-i));
    for(i=max(0ll,a+c-b);i<=l;i++)m-=pre[min(b+i-a-c,l-i)],printf("%lld--\n",min(b+i-a-c,l-i));
    for(i=max(0ll,b+a-c);i<=l;i++)m-=pre[min(c+i-b-a,l-i)],printf("%lld--\n",min(c+i-b-a,l-i));
    printf("%lld\n",m);
    return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[3], l;
	cin >> a[0] >> a[1] >> a[2] >> l;

	long long total = (l + 1) * (l + 2) * (l + 3) / 6;
	int perimeter = a[0] + a[1] + a[2];
	for (int i = 0; i < 3; i++)
	{
		int sides_length = perimeter - a[i];
		for (int extension = max(sides_length - a[i], 0); extension <= l; extension++)
		{
			long long diff = min(l - extension, a[i] + extension - sides_length);
			total -= (diff + 1) * (diff + 2) / 2;
		}
	}

	cout << total;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int i,j,l,m,n,a,b,c;
    cin>>a>>b>>c>>l;
    long long sum=0,k;

    for(i=0;i<=l;i++)
    {
        if(a+i>=b+c)
        {
            m=min(a+i-b-c,l-i);
            sum+=((m+1)*(m+2))/2;
        }

    }
     for(i=0;i<=l;i++)
    {
        if(b+i>=a+c)
        {
            m=min(b+i-a-c,l-i);
            sum+=((m+1)*(m+2))/2;
        }

    }
     for(i=0;i<=l;i++)
    {
        if(c+i>=b+a)
        {
            m=min(c+i-b-a,l-i);
            sum+=((m+1)*(m+2))/2;
        }

    }
    k=((l+3)*(l+2)*(l+1))/6 -sum;
    cout<<k<<endl;

}

#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

typedef long long ll;

int main(int argc, char **argv) {
    int a,b,c,l;
    ll comb;
    cin >> a >> b >> c >> l;
    comb = 1LL*(l+1)*(l+2)*(l+3)/6;

    if(a < b) swap(a,b);
    if(a < c) swap(a,c);

    ll untri = 0;
    for(int i = 0; i <= l; i++) {
        int x = max(0,min(a-b-c+i,l-i));
        untri += 1LL*(x+1)*(x+2)/2;
    }

    ll result = comb - untri;
    cout << result << endl;

    return 0;
}

#include<cstdio>
#include<list>
using namespace std;

struct point
{
	int x, y;
	point(const int _x, const int _y) : x(_x), y(_y){}
};

long long solve(int a, int b, int u, int d)
{
	if( a<=0 || b<=0 || u<=d || a+b<=d )
		return 0;

	list<point> L;

	if( d<=-2 )
		L.push_back(point(-1, -1));
	else
	{
		if( d+1>a )
		{
			L.push_back(point(a, -1));
			L.push_back(point(a, d-a));
		}
		else
		{
			L.push_back(point(d+1, -1));
		}

		if( d+1>b )
		{
			L.push_front(point(-1, b));
			L.push_front(point(d-b, b));
		}
		else
		{
			L.push_front(point(-1, d+1));
		}
	}

	if( u>=a+b )
		L.push_back(point(a, b));
	else
	{
		if( u-a<-1 )
		{
			L.push_back(point(u+1, -1));
			L.push_back(point(a, -1));
		}
		else
		{
			L.push_back(point(a, u-a));
		}

		if( u-b<-1 )
		{
			L.push_front(point(-1, u+1));
			L.push_front(point(-1, b));
		}
		else
		{
			L.push_front(point(u-b, b));
		}
	}

	long long area=0, edge=L.size();
	L.push_back(L.front());

	for(list<point>::iterator itl=L.begin(); ; ++itl)
	{
		++itl;
		list<point>::iterator itr=itl;
		--itl;

        if( itr==L.end() )
            break;

		area+=itl->x*itr->y-itl->y*itr->x;

		if( itl->x==itr->x )
            edge+=itl->y>itr->y ? itl->y-itr->y-1 : itr->y-itl->y-1;
		else
            edge+=itl->x>itr->x ? itl->x-itr->x-1 : itr->x-itl->x-1;
	}

    if( area<0 )
        area=-area;

	return (area-edge+2)>>1;
}

long long solve1(int a, int b, int c, int l)
{
	long long ans=0;

	for(int i=0; i<=l; i++)
	{
		int aa=a+i;
		ans+=solve(aa-b, aa-c, l-i+1, aa-b-c);
	}

	return ans;
}

long long solve2(int a, int b, int c, int l)
{
	if( a<b )
		return solve2(b, a, c, l);

	long long ans=0;

	for(int i=0; i<=l; i++)
	{
		int ll=l-i-(a+i-b);
		int dd=a+i-c-1;

		if( ll>=0 && dd>=0 )
			ans+=(ll<dd ? ll : dd)+1;
	}

	return ans;
}

long long solve3(int a, int b, int c, int l)
{
	int max=0;

	if( max<a )
		max=a;

	if( max<b )
		max=b;

	if( max<c )
		max=c;

	l-=max-a;
	l-=max-b;
	l-=max-c;

	if( l<0 )
		return 0;
	else
		return l/3+1;
}

int main()
{
	int a, b, c, l;
	scanf("%d%d%d%d", &a, &b, &c, &l);
	long long ans1=solve1(a, b, c, l)+solve1(b, c, a, l)+solve1(c, a, b, l);
	long long ans2=solve2(a, b, c, l)+solve2(b, c, a, l)+solve2(c, a, b, l);
	printf("%I64d\n", ans1+ans2+solve3(a, b, c, l));
}

#include <cstdio>
#include <algorithm>
#include<math.h>
#include<string.h>
#include<memory.h>
#include<iostream>
#include<vector>
using namespace std;
int a,b,c,l;
int main(){
//freopen("in.txt","r",stdin);
scanf("%d%d%d%d",&a,&b,&c,&l);
long long ans=0;
int i,j;
for(i=0;i<=l;i++)
    ans+=(long long)(l+1)*(l+2)/2;
long long num=0;
for(i=0;i<=l;i++){
    if(b+c<=a+i){
        num=min(l-i,a+i-b-c);
        ans-=(num+1)*(num+2)/2;
    }
    if(a+c<=b+i){
        num=min(l-i,b+i-a-c);
        ans-=(num+1)*(num+2)/2;
        }
    if(a+b<=c+i){
        num=min(l-i,c+i-a-b);
        ans-=(num+1)*(num+2)/2;
        }

}
printf("%I64d\n",ans);
return 0;
}

#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>

template <typename T>
void resize(int n, vector<T> &u) {
  u.resize(n);
}

template <typename Head, typename... Tail>
void resize(int n, Head &H, Tail&... T) {
  resize(n, H);
  resize(n, T...);
}

template <typename T>
void debug_out(T t) {
  cerr << t;
}

template <typename A, typename B>
void debug_out(pair<A, B> &u) {
  cerr << "(" << u.first << " " << u.second << ")";
}

template <typename T>
void debug_out(vector<T> &t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << ", ";
  }
}

template <typename T>
void debug_out(vector<vector<T>> &t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << endl;
  }
}

vector<char> lowchar = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> hichar = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char> base_10 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

template <typename T>
string to_string(T t) {
  ostringstream ss;
  ss << t;
  return ss.str();
}

long long to_num(string t) {
  long long res = 0;
  for(int i = 0; i < (int) t.length(); i++) {
    res *= 10;
    res += t[i] - '0';
  }
  return res;
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__), cerr << endl;
#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int a, b, c, l;

long long solvetriange(long long s) {
  if(s < 0) return 0;
  return (s + 1) * (s + 1) - s * (s + 1) / 2;
}

long long get(long long da, long long db, long long ds) {
  if(ds < 0 || ds > da + db) return 0;
  if(da < db) swap(da, db);
  if(ds <= db || ds >= da) {
    if(ds <= db) return solvetriange(ds);
    else {
      return (da + 1) * (db + 1) - solvetriange(da + db - ds - 1);
    }
  }
  return solvetriange(db - 1) + (ds - db) * (db + 1);
}

long long solve(int s) {
  long long da = s + b + c - a - 1;
  if(da % 2 != 0) da--;
  da /= 2;
  if(da < 0) return 0;
  long long db = s + a + c - b - 1;
  if(db % 2 != 0) db--;
  db /= 2;
  if(db < 0) return 0;
  long long ds = s - a - b + c + 1;
  if(ds % 2 != 0) ds++;
  ds /= 2;
  if(ds > s) return 0;
  return (da + 1) * (db + 1) - get(da, db, ds - 1) - get(da, db, da + db - s - 1);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b >> c >> l;
  long long res = 0;
  range(i, 0, l + 1) res += solve(i);
  cout << res;
  return 0;
}

//容斥原理：总方案数-不构成三角形的方案数
//L个求 放到4个盒子里C(L+3, 3)-->L+3的位置放3块隔板
//L个球 选i=0 to L放到三个盒子里sigma C(L+2, 2)
//枚举最长边假设a+i为最长边
//i = b + c - a to L
//对于这个i的方案数应为a+i为最长边的方案数，既能给b,c的最长的木棍长度x=min(a+i-b-c,L-i)C(x+2,2)
#include<iostream>
using namespace std;
int a, b, c, l;
long long ans;
long long work(int a, int b, int c, int l){ // 以a+i为最长边
	long long ret = 0;
	for (int i = max(0, b+c-a); i <= l; i++){ // 此处可能<0
		long long x = min(a+i-b-c, l-i);
		ret += (x+1) * (x+2) / 2;
	}
	return ret;
}
int main(){
	cin >> a >> b >> c >> l;
	//C(n,3) = n!/3!/(n-3)! --> n*(n-1)*(n-2)/6
	ans = (l + 3) * (l + 1) * (l + 2) / 6;
	ans -= work(a,b,c,l);
	ans -= work(b,a,c,l);
	ans -= work(c,a,b,l);
	cout << ans << endl;
	return 0;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

long long a, b, c, l;
long long ans = 0;
int main() {
    cin >> a >> b >> c >> l;
    for (int i = 0; i <= l; i++) {
        long long peri = a + b + c + i;
        long long nways = ((i + 2) * (i + 1)) / 2;
        long long nbadways = 0;
        long long half = (peri + 1) / 2;
        // if a breaks it
        long long a_uses = max(0LL, half - a);
        long long l_remaining = max(-1LL, i - a_uses);
        nbadways += (((l_remaining + 1) * (l_remaining + 2)) / 2);

        long long b_uses = max(0LL, half - b);
        l_remaining = max(-1LL, i - b_uses);
        nbadways += (((l_remaining + 1) * (l_remaining + 2)) / 2);

        long long c_uses = max(0LL, half - c);
        l_remaining = max(-1LL, i - c_uses);
        nbadways += (((l_remaining + 1) * (l_remaining + 2)) / 2);

        // cout << "\nnways: " << nways << ", nbadways: " << nbadways;

        ans += nways - nbadways;
    }

    cout << ans;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;

long long ans;
long long a[5],l,t,s;
long long L,R,ta,tb,tc;
int main()
{
    while(~scanf("%I64d%I64d%I64d%I64d",&a[0],&a[1],&a[2],&l))
    {
        ans = 0;
        sort(a,a+3);
        if(a[0]+a[1]>a[2]) ans++;
        L = max(a[2]-a[1]-a[0],0LL);
        R = min(l,a[1]+a[2]-a[0]-1);
        ans += R-L;
        R = min(l,a[2]+a[0]-a[1]-1);
        ans += R-L;
        R = min(l,a[1]+a[0]-a[2]-1);
        ans += max(R,0LL);
        //cout << ans <<endl;
        for(long long i=2;i<=l;i++)
        {
            s = a[0]+a[1]+a[2]+i;
            t =(s-1)/2;
            ta = min(i-1,t-a[0]);
            tb = min(i-1,t-a[1]);
            tc = min(i-1,t-a[2]);
           // cout <<ta << " " << tb <<" " << tc <<endl;
            if(a[2]<=t) ans += max(0LL,ta-(i-1-tb));
            ans += max(0LL,ta-(i-1-tc));
            ans += max(0LL,tb-(i-1-tc));
        }
        cout << ans<<endl;
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int mark;
int And(int a,int b,int c)
{
	//printf("%d %d %d\n",a,b,c);
	if(a+b<=c||a+c<=b||b+c<=b)
		mark=1;
	return mark;
}
int main()
{
	int i,j,k,m,n,a,b,c,l;
	while(~scanf("%d%d%d%d",&a,&b,&c,&l))
	{
		m=0;
		for(i=0;i<=l;i++)
			for(j=0;j<=l-i;j++)
				for(k=0;k<=l-i-j;k++)
				{
					mark=0;
					And(a+i,b+j,c+k);
					if(mark==0)	m++;
				}
		printf("%d\n",m);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long i,i0,n,m,a,b,c,l;
int main()
{
    scanf("%lld %lld %lld %lld",&a,&b,&c,&l);
    for(i=0;i<=l;i++)
    {
        m+=2*abs(i-1)*max(0ll,((l-i)-max(0ll,a+i-b-c+1)));
    }
    printf("%lld\n",m);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 300000 + 10;

long long x[MAXN];

int main() {
    int a, b, c, l;
    scanf("%d%d%d%d", &a, &b, &c, &l);

    long long ans = (l+3)*(l+2)*(l+1)/6;
    for(int i=0; i<=l; i++) {
        if(a+i >= b+c) {
            int tmp = min(l-i, a+i-b-c);
            ans -= (tmp+2)*(tmp+1)/2;
        }
        if(b+i >= a+c) {
            int tmp = min(l-i, b+i-a-c);
            ans -= (tmp+2)*(tmp+1)/2;
        }
        if(c+i >= a+b) {
            int tmp = min(l-i, c+i-a-b);
            ans -= (tmp+2)*(tmp+1)/2;
        }
    }

    printf("%lld\n", ans);

    return 0;
}
// ntuj - 6qyih036cdi32yq74ztbc

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <climits>
#include <utility>

#include <fstream>
#include <memory>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
#define debug(v) cout << "Variable is " << v << endl;
#define PA(A,i,n) for(int i = 0; i < n; i++) cout << A[i] << " "; cout << endl;
#define FOR(a, b, n) for(int (a) = (b); (a) < (n); a++)
#define LL long long
#define ALL(v) v.begin(),v.end()
#define ZERO(v) memset(v, 0, sizeof v)
#define NEG(v)  memset(v, -1, sizeof v)
#define PI 3.141592653589793
#define MOD 1000000007
inline double min(double a , double b) {if(a < b)return a; return b;}

int n, k;
int arr1[100010];
int arr2[100010];

LL solve(LL a, LL b, LL c, int l)
{
    LL res =0;
    for(int i = 0; i <= l; i++)
    {
        if(b + c > a + i)
            continue;
        LL x = min(l - i, a + i - b - c);
        res += (x + 1 ) * (x + 2) / 2;
    }
    return res;
}

int main(){
    int a,b,c,l;
    cin >> a >> b >> c >> l;
    LL res = (l + 3) * (l + 2 ) * (l + 1) / 6;
    res -= solve(a,b,c,l);
    res -= solve(b,c,a,l);
    res -= solve(c,b,a,l);
    cout << res << endl;

}

#include<cstdio>//容斥原理
#include<iostream>
using namespace std;

typedef long long ll;

int main()
{
    ll a, b, c, l;
    while(cin >> a >> b >> c >> l)
    {
        ll ans = 0;
        for(int i = 0; i <= l; i++)
        {
            ll p = a + b + c + i;
            ll s = (p - 1) / 2;
            if(a > s || b > s || c > s) continue;
            ans += (i + 2) * (i + 1) / 2;//总长为i的三角形有多少种情况，组合数C(i + 2, 2)
            if(a + i > s) ans -= (a + i - s - 1 + 2) * (a + i - s - 1 + 1) / 2;//分别枚举a,b,c作为第三边，减去不符合条件的情况
            if(b + i > s) ans -= (b + i - s - 1 + 2) * (b + i - s - 1 + 1) / 2;
            if(c + i > s) ans -= (c + i - s - 1 + 2) * (c + i - s - 1 + 1) / 2;
        }
        cout << ans << endl;
    }
    return 0;
}

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <complex>
#include <cstdio>
#include <vector>
#include <cctype>
#include <string>
#include <ctime>
#include <cmath>
#include <set>
#include <map>

typedef long double LD;
typedef long long LL;

using namespace std;

#define sz(A) (int)(A).size()
#define mp make_pair
#define pb push_back

LL res = 0, res2 = 0, res3 = 0;
int a, b, c, l;

LL sum(int a, int b) {
    return LL(a) * (b - a + 1) + LL(b - a + 1) * (b - a + 2) / 2;
}

void solve() {
    for (int da = 0; da <= l; da++) {
        int newA = a + da;

        if (newA >= b && newA >= c) {
            if (newA - b + newA - c + da <= l) {
                res3++;
            }
        }

        if (newA <= b || newA <= c) {
            continue;
        }
        int must = newA + 1 - (b + c), restl = l - da;
        if (must > restl) {
            continue;
        }
        res += sum(must, restl);
        int forb_db = a + da - b;
        if (forb_db <= restl) {
            int restl2 = restl - forb_db;
            int must2 = newA + 1 - (b + forb_db + c);
            res -= sum(must2, restl2);
        }
        int forb_dc = a + da - c;
        if (forb_dc <= restl) {
            int restl2 = restl - forb_dc;
            int must2 = newA + 1 - (b + c + forb_dc);
            res -= sum(must2, restl2);
        }
        if (forb_db + forb_dc <= restl) {
            int restl2 = restl - forb_db - forb_dc;
            int must2 = newA + 1 - (b + forb_db + c + forb_dc);
            res += sum(must2, restl2);
        }
    }

    for (int maxSide = max(b, c); maxSide <= max(b, c) + l; maxSide++) {
        int db = maxSide - b, dc = maxSide - c;
        if (db + dc <= l && maxSide > a) {
            int restl = l - db - dc;
            res2 += min(a + restl, maxSide - 1) - a + 1;
        }
    }
}

int main() {
    cin >> a >> b >> c >> l;
    solve();
    swap(a, b);
    solve();
    swap(a, c);
    solve();

    cout << res + res2 + res3 / 3 << endl;

    return 0;
}

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
long long int func(long long int x)
{
    return (x+1)*(x+1)/2;
}
int main()
{
    long long int  a,b,c,l;
    cin>>a>>b>>c>>l;
    long long int ans=0;
    long long int i,j,k;
    for(i=0;i<=l;i++)
    {
        long  long int hehe=(b+c-a+i)/2;
        if((b+c-a+i)%2==1)
            hehe++;
        long long int haha=(a+b-c+i)/2;
        if((a+b-c+i)%2)
            haha++;
        long long int hehehaha=(c+a-b+i)/2;
            if((c+a-b+i)%2)
                hehehaha++;
        if(hehe<=0||haha<=0||hehehaha<=0)
            continue;
        ans+=(i+1)*(i+2)/2;
        if(i>=hehe)
            ans-=func(i-hehe);
        if(i>=haha)
            ans-=func(i-haha);
        if(i>=hehehaha)
            ans-=func(i-hehehaha);
        if(i>=hehe+haha)
            ans+=func(i-hehe-haha);
        if(i>=hehe+hehehaha)
            ans+=func(i-hehe-hehehaha);
        if(i>=haha+hehehaha)
            ans+=func(i-haha-hehehaha);
        if(i>=hehe+haha+hehehaha)
            ans+=func(i-hehe+haha-hehehaha);
    }
    cout<<ans<<endl;
}

#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <functional>

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define RT fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vpii;

const int INFint = 2147483647;
const ll INF = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const ld EPS = 1e-9;

ll f(ll a, ll b, ll c, ll l){
    if (a < b + c)
        return 0;
    ll cr = min(l, a - b - c);
    return (cr + 1) * (cr + 2) / 2;
}

int main(){
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("/Users/qjex/prj/olymp/olymp0/olymp0/input.txt", "r", stdin); freopen("/Users/qjex/prj/olymp/olymp0/olymp0/output.txt", "w", stdout);
#else
    //    freopen("FILE.in", "r", stdin); freopen("FILE.out", "w", stdout);
    //    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int a, b, c, l;
    cin >> a >> b >> c >> l;
    ll ans = (l + 1) * (l + 2) * (l + 3) / 6;
    for(int i = 0; i <= l; i++){
        ans-= f(a + i, b, c, l - i);
        ans-= f(b + i, a, c, l - i);
        ans-= f(c + i, b, a, l - i);
    }
    cout << ans << endl;
    RT
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long check(long long a, long long b, long long c, long long r){
	if (b + c > a){
		return 0;
	}
	int d = min(r, a - b - c);
	return (d+2)*(d+1)/2;
}

int main(){
	long long a, b, c, l;
	long long total;

	cin >> a >> b >> c >> l;

	total = (l+3)*(l+2)*(l+1)/6;

	for (int i=0; i<=l; i++){
		total -= check(a+i, b, c, l-i);
		total -= check(b+i, a, c, l-i);
		total -= check(c+i, a, b, l-i);
	}

	cout << total << "\n";
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<map>
#include<queue>
#include<iterator>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define CLR(a) memset(a,0,sizeof(a))
#define ll long long
#include<ctime>
#include<cmath>
#include<vector>
#include<iostream>

int a, b, c, n, low, reallow, high, realhigh, k, x, y, z, w;
ll ans;

void solve3(int a, int b, int c, int n)
{
	FOE(i, 1, 600000)
	{
		if (a > i || b > i || c > i) continue;
		if (i * 3 - a - b - c > n) break;
		ans++;
	}
}

void solve2(int a, int b, int c, int n)
{
	FOE(i, 1, 600000)
	{
		if (a > i || b > i || c > i) continue;
		if (i + i - a - b > n) break;
		ans += (ll)(min(n - (i + i - a - b) + 1, i - c));
	}
}

void solve1(int a, int b, int c, int n)
{
//	printf("top %d %d %d\n", a, b, c);

	FOE(i, 1, 600000)
	{
	//	printf("hii %d %d %d %d %d\n", a, b, c, n, i);
		if (a > i || b >= i || c >= i) continue;
		if (i - a > n) break;

		ans += (ll)((ll)(i - b) * (ll)(i - c));

		high = i + i - 2;
		realhigh = b + c + (n - (i - a));
		low = b + c;
		reallow = i + 1;

		realhigh = min(realhigh, high);
		reallow = max(reallow, low);

	//	printf("hi %d %d %d\n", i, reallow, realhigh);
		//reallow to realhigh

		if (reallow > realhigh) { ans -= (ll)((ll)(i - b) * (ll)(i - c)); continue; }

		reallow--;
		realhigh++;

		k = min(i - b, i - c);

		if (realhigh <= high)
		{
			x = min(high - realhigh + 1, k);
			ans -= (ll)x * (ll)(x + 1) / 2ll;
			if (high - realhigh + 1 > k) ans -= (ll)(k) * (high - realhigh + 1 - k);
		}

		if (low <= reallow)
		{
			x = min(reallow - low + 1, k);
			ans -= (ll)x * (ll)(x + 1) / 2ll;
			if (reallow - low + 1 > k) ans -= (ll)(k) * (reallow - low + 1 - k);
		}
	}
}

int main ()
{
	scanf("%d %d %d %d", &a, &b, &c, &n);

	solve3(a, b, c, n);

	solve2(a, b, c, n);
	solve2(a, c, b, n);
	solve2(b, c, a, n);

	solve1(a, b, c, n);
	solve1(b, a, c, n);
	solve1(c, a, b, n);

	printf("%I64d\n", ans);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,c,l;ll ans;
ll cat(int a,int s){
	ll ans=0;
	int k=s-a;// x-k>=y+z
	for(int x=k;x<=l;x++){
		ll mi=min(x-k,l-x);
		ans+=(mi+2)*(mi+1)/2;
	}return ans;
}
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&l);
	ans=1ll*(l+3)*(l+2)*(l+1)/6;
	ans-=cat(a,b+c)+cat(b,a+c)+cat(c,b+a);
	if(ans<0)puts("0");
	else cout<<ans<<endl;
}

#pragma comment(linker,"/stack:67108864")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <climits>
#include <cfloat>
#include <functional>
#include <ctime>
#include <numeric>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <utility>
#include <bitset>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <typeinfo>
#include <cassert>
#include <ctime>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forn1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = int(n); i > 0; --i)
#define foran(i, a, n) for(int i = int(a); i <= int(n); ++i)

#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define all(v) (v).begin(),(v).end()

typedef long double ld;
typedef long long ll;

const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
const ll INF = 1000 * 1000 * 1000 + 9;
const int NMAX = 1000*1000 + 3;

int a, b, c, l;

inline bool read()
{
    if (!(cin >>a >>b >>c >>l))
        return false;
    return true;
}

ll calc(int a, int b, int len)
{
	ll ans = 0;
	if (a > b) swap(a, b);
	if (len <= a)
		ans = (len + 1) * (len + 2) / 2;
	if (a < len && len < b)
		ans = (len - a + 1 + len + 1) * (a + 1) / 2;
	if (b <= len && len < a + b)
	{
		int a_f = a + b - len;
		ans = (a_f + 1) * (b + 1);
		ans += (a - a_f) * (a + b - len + b) / 2;
	}
	if (len >= a + b)
		ans = (a + 1) * (b + 1);
	return ans;
}

ll calc(int a, int b, int c, int l)
{
	ll ans = 0;
	forn(i, l + 1)
	{
		int newa = a + i;
		if (b + c + l - i <= newa) continue;
		int addmin = max(0, newa - b - c + 1);
		int addmax = l - i;
		int mlb = newa - b - 1;
		int mlc = newa - c - 1;
		if (mlb < 0 || mlc < 0) continue;
		if (mlb + mlc < addmin) continue;
		ans += calc(mlb, mlc, addmax) - calc(mlb, mlc, addmin - 1);
		//cerr <<mlb <<' ' <<mlc <<' ' <<addmax <<endl;//calc(mlb, mlc, addmax) <<endl;
	}
	return ans;

}

ll calc1(int a, int b, int c, int l)
{
	ll ans = 0;
	forn(i, l + 1)
	{
		int newa = a + i;
		int newb = newa;

		if (newb < b) continue;
		int addmin = i + (newb - b) ;
		if (addmin > l) continue;
		if (newa <= c) continue;
		ans += min(l - addmin + 1, newa - c);
	}
	return ans;
}

ll calc2(int a, int b, int c, int l)
{
	ll ans = 0;
	forn(i, l + 1)
	{
		int newa = a + i;
		int newb = newa;
		int newc = newa;

		if (newb < b) continue;
		if (newc < c) continue;
		int addmin = i + (newb - b) + (newc - c) ;
		if (addmin > l) continue;
		ans ++;
	}
	return ans;
}

inline void solve()
{
	ll ans = 0;
	ans += calc(a, b, c, l);
	ans += calc(b, a, c, l);
	ans += calc(c, a, b, l);
	ans += calc1(a, b, c, l);
	ans += calc1(a, c, b, l);
	ans += calc1(b, c, a, l);
	ans += calc2(a, b, c, l);
	cout <<ans <<endl;
}

int main()
{
    ifstream ifile("input.txt");
    if (ifile) {
        freopen("input.txt", "rt", stdin);
    }
#ifdef ONLINE_JUDGE
    if (ifile) {
        freopen("output.txt","wt",stdout);
    }
#endif
    while(read())
        solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
long long ans;
const int mod = 1e9 + 7;
int rec (int a ,int b ,int c ,int s){
	if(s+a < b+c)   return 0;
	int cur = min(s,(s+a-b-c)/2);
	return  (cur+1)*(cur+2)/2;
}
int main(){
	int a[4];
	int l;
	cin>>a[0]>>a[1]>>a[2]>>l;
	for(int i=0;i<=l;i++){
		ans += (((l-i+1)*(l-i+2))/2)%mod;
	}
//	cout<<ans<<endl;
	for(int i=0;i<3;i++){
		for(int j=0;j<=l;j++){
			ans -= rec(a[i],a[(i+1)%3],a[(i+2)%3],j)%mod;
		}
	}
	cout<<ans;
	return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <complex>
#define MINF 0xc0c0c0c0
#define INF 0x3f3f3f3f
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ll> pt;

int a[3], l;

int main()
{
    ios::sync_with_stdio(0);
    cin >> a[0] >> a[1] >> a[2] >> l;
    sort(a, a+3);
    ll ans = 0;
    for (int m = a[2]; m <= a[2]+l; ++m)
    {
        if (3*m - a[0] - a[1] - a[2] <= l) // all max
            ++ans;
        for (int i = 0; i < 3; ++i)
        {
            int i1 = (i+1)%3, i2 = (i+2)%3;
            // all but i are max
            int hiL = l + a[i1] + a[i2] - 2*m;
            int top = min(m - 1, a[i] + hiL);
            ans += max(0, top - a[i] + 1);
            // only i is max
            hiL = l + a[i] - m;
            int loL = m - a[i1] - a[i2] + 1;
            int hiX = m - 1 - a[i1];
            int hiY = m - 1 - a[i2];
            vector<int> xs, ys;
            xs.push_back(0);
            xs.push_back(hiX);
            xs.push_back(loL);
            xs.push_back(loL - hiY);
            xs.push_back(hiL);
            xs.push_back(hiL - hiY);
            sort(xs.begin(), xs.end());
            for (int i = 0; i < xs.size(); ++i)
            {
                int ylo = max(0, loL - xs[i]);
                int yhi = min(hiY, hiL - xs[i]);
                ys.push_back(max(0, yhi - ylo + 1));
            }
            for (int i = 1; i < xs.size(); ++i)
            {
                if (xs[i-1] < 0 || xs[i] > hiX)
                    continue;
                ans += ll(xs[i] - xs[i-1] + 1) * ll(ys[i-1] + ys[i]) / 2;
                if (xs[i-1] != 0)
                    ans -= ys[i-1];
            }
        }
    }
    cout << ans << endl;
}

using namespace std;

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <sstream>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <tuple>
#include <queue>

using namespace std;

long calcBad(long a, long b, long c, long l) {
    long bad = 0;
    for (long da = 0; da <= l; ++da) {
        long nA = a + da;
        long nL = l - da;
        long x = min(nL, nA - b - c);
        if (x >= 0)
            bad += (x + 1) * (x + 2) / 2;
    }
    return bad;
}

void solve() {
    long a,b,c,l;
    cin >> a >> b >> c >> l;

    long total = (l + 1) * (l + 2) * (l + 3) / 6;
    total -= calcBad(a,b,c,l);
    total -= calcBad(b,a,c,l);
    total -= calcBad(c,a,b,l);

    cout << total << endl;
}

int main() {
#ifdef LANGO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();
    return 0;
}

/* AKSHIT CHOPRA 2014A7PS035P BITS Pilani */
#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define endl '\n'
#define spc ' '
#define pi 2*acos(0.0)
#define mp make_pair
#define fi first
#define sc second
#define pb push_back
#define forup(i,a,b) for( __typeof(b) i = a; i<=b ; ++i )
#define fordwn(i,a,b) for( __typeof(b) i = a; i<=b ; --i )
void io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
/* fast i/o */
/*
int get_int()
{
    int num = 0;
    char c = getchar_unlocked();
    int flag = 0;
    while(!((c>='0' && c<='9') || c == '-'))
        c=getchar_unlocked();
    if(c == '-')
    {
        flag = 1;
        c=getchar_unlocked();
    }
    while(c>='0' && c<='9')
    {
        num = (num<<1)+(num<<3)+c-'0';
        c=getchar_unlocked();
    }
    if(flag==0)
        return num;
    else
        return -1*num;
}
*/
template <typename T> T abs(T &n) {return (n < 0 ? -n : n);}
template <typename T> T max(T &a, T &b) {return (!(a < b) ? a : b);}
template <typename T> T min(T &a, T &b) {return (a < b ? a : b);}
template <typename T> T mod(T a, T b) {return (a < b ? a : a % b);}
LL mulmod(LL a,LL b, LL m){LL q=(LL)(((long double)a*(long double)b)/(long double)m);LL r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}/* for TOO LARGE mod of the order 10^18 etc */
template <typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mod(x*p, m);p=mod(p*p, m);n>>=1;}return x;}
template <typename T>T power(T e,T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template <typename T> T InverseEuler(T a, T m){return (a==1? 1 : power(a, m-2, m));}/*use IFF m is a prime number */
template <typename T> T gcd(T a, T b){return (!b)? a:gcd(b,a%b);}
template <typename T> T lcm(T a, T b){return (a*(b/gcd(a,b)));}
LL solve(LL a,LL b,LL c,LL l)
{
    int x = min(a-b-c,l) ;
    if(x < 0)
        return 0 ;
    return ((x+1)*(x+2)/2) ;
}
int main(int argc,char *argv[])
{
    io() ;
    LL l ;
    LL a,b,c ;
    cin >> a >> b >> c >> l;
    LL tot = (l+3)*(l+2)*(l+1)/6 ;
    LL cnt = 0 ;
    for(int i=0;i<=l;i++)
    {
        cnt += solve(a+i,b,c,l-i) ;
        cnt += solve(b+i,a,c,l-i) ;
        cnt += solve(c+i,a,b,l-i) ;
    }
    cout << (tot - cnt) << endl ;

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <cctype>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;

LL a, b, c, l, p1, p2, t1, t2;

int main()
{
    scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &l);
    t1 = a + b - c + l; t2 = c + b - a + l;
    if (t1 % 2) p1 = min(t1 / 2, l) + 1; else p1 = min(t1 / 2 - 1, l) + 1;
    if (t2 % 2) p2 = min(t2 / 2, l) + 1; else p2 = min(t2 / 2 - 1, l) + 1;
    printf("%I64d\n", p1 * p2);
}

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define X first
#define Y second

using namespace std;
using i64 = long long;
using Pii = pair<int, int>;

constexpr int MAX = 128;

Pii p[MAX], q[MAX];

bool check(const Pii& p, int s1, int s2, int r1, int r2) {
  return p.X + p.Y >= s1 && p.X + p.Y <= s2 &&
      p.X >= 0 && p.X <= r1 && p.Y >= 0 && p.Y <= r2;
}

i64 norm(const Pii& p) {
  return (i64)p.X * (i64)p.X + (i64)p.Y * (i64)p.Y;
}

bool cmp(const Pii& a, const Pii& b) {
  i64 r = (i64)a.X * (i64)b.Y - (i64)a.Y * (i64)b.X;
  return r == 0 ? norm(a) < norm(b) : r > 0;
}

int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
}

i64 cross(const Pii& a, const Pii& b, const Pii& c) {
  Pii u{b.X - a.X, b.Y - a.Y}, v{c.X - a.X, c.Y - a.Y};
  return (i64)u.X * (i64)v.Y - (i64)u.Y * (i64)v.X;
}

i64 calc(int s1, int s2, int r1, int r2) {
  if (r1 < 0 || r2 < 0 || s1 > s2) return 0;
  int n = 0, m = 0;
  p[n++] = {0, 0}; p[n++] = {r1, 0}; p[n++] = {0, r2}, p[n++] = {r1, r2};
  p[n++] = {s1, 0}; p[n++] = {0, s1};
  p[n++] = {s2, 0}; p[n++] = {0, s2};
  p[n++] = {r1, s1 - r1}; p[n++] = {s1 - r2, r2};
  p[n++] = {r1, s2 - r1}; p[n++] = {s2 - r2, r2};
  for (int i = 0; i < n; ++i) {
    if (check(p[i], s1, s2, r1, r2)) {
      q[m++] = p[i];
    }
  }
  if (!m) return 0;
  sort(q, q + m);
  m = unique(q, q + m) - q;
  //printf("m = %d\n", m);
  //for (int i = 0; i < m; ++i) {
  //  printf("p = [%d, %d]\n", q[i].X, q[i].Y);
  //}
  if (m < 2) return m;
  Pii o = q[0];
  for (int i = 0; i < m; ++i) {
    q[i].X -= q[0].X; q[i].Y -= q[0].Y;
  }
  sort(q + 1, q + m, cmp);
  q[m] = q[0];
  i64 area = 0, bound = 0;
  for (int i = 2; i < m; ++i) {
    i64 cur = cross(q[0], q[i - 1], q[i]);
    area += (cur < 0 ? - cur : cur);
  }
  for (int i = 0; i < m; ++i) {
    bound += gcd(abs(q[i].X - q[i + 1].X), abs(q[i].Y - q[i + 1].Y));
  }
  i64 inter = (area - bound) / 2 + 1;
  return inter + bound;
}

int upper2(int x) {
  return x < 0 ? x / 2 : (x + 1) / 2;
}

int lower2(int x) {
  return x < 0 ? (x - 1) / 2 : x / 2;
}

i64 solve(int a, int b, int c, int l) {
  i64 ret = 0;
  for (int i = 0; i <= l; ++i) {
    int s1 = upper2(i + c - a - b + 1);
    int s2 = i;
    int r1 = lower2(b + c - a + i - 1);
    int r2 = lower2(a + c - b + i - 1);
    ret += calc(s1, s2, r1, r2);
  }
  return ret;
}

int main() {
  int a, b, c, l;
  while (cin >> a >> b >> c >> l) {
    cout << solve(a, b, c, l) << endl;
  }
  return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a; i <= b; i++)
typedef long long LL;
using namespace std;
LL calc(int a, int i, int *b) {
	LL ans = 0;
	if (a < 0) return 0; else a += 2; int c[4] = {1, -1, -1, 1};
	rep(s,0,3) {
		int t = a, cnt = 0;
		rep(k,0,2) if (k != i) t -= (s >> cnt & 1) ? b[k] : 0, cnt++;
//		cout <<s<<' '<<t<<endl;
		if (t >= 0) ans += 1LL * t * (t - 1) / 2 * c[s];
	}
//	cout <<a<<' '<<i<<' '<<b[0]<<' '<<b[1]<<' '<<b[2]<<' '<<ans<<endl;
	return ans;
}

int main() {
	int a[3], l; cin >>a[0]>>a[1]>>a[2]>>l; long long ans = 0;
	rep(i,0,2) {
		rep(j,0,l) {
			bool f = true;
			rep(k,0,2) if (mp(a[k], k) > mp(a[i] + j, i)) { f = false; break; }
			if (!f) break;

			int b[3];
			rep(k,0,i - 1) b[k] = a[i] + j - a[k] + 1;
			rep(k,i + 1,2) b[k] = a[i] + j - 1 - a[k] + 1;

			int rest = l - j, need = a[i] + j; rep(k,0,2) if (k != i) need -= a[k];
			if (rest < need) break;

			ans += calc(rest, i, b) - calc(need - 1, i, b);
		}
	}
	cout <<ans<<endl;
}

#include <bits/stdc++.h>
#define maxx 501
#define mod 1000000007
#define pii pair<int,int>
#define piipii pair<pii,pii>
typedef long long ll;

using namespace std;

ll a, b, c, l;
ll down1, up1, down2, up2, d1, d2;

ll odd(ll down, ll up){

    if(down % 2 == 0)
        down++;
    if(up % 2 == 0)
        up --;

    if(up < down)
        return 0;

    return (up - down)/2 + 1;
    }

ll even(ll down, ll up){

    if(up < down)
        return 0;

    return (up - down + 1 - odd(down, up));
    }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    cin >> a >> b >> c >> l;

    ll ans = 0;
    ll zero = 0;

    while(l >= 0)
    {
       down1 = c - b - a + 1;
       up1 = c - b + a - 1;
       down2 = max(down1, max(zero, a - c - b + 1));
       if(down1 < -down2)
        down1 = -down2;

       up2 = l;
       if(down2 > up2)
        break;

       ans = ans + odd(down1, up1)*odd(down2, up2);
       //cout << ans << endl;
       d1 = odd(max(down2 + 2, down1), up1);
       d2 = odd(max(up2 + 2, down1), up1);
       if(up2 == down2 && up2 % 2 == 0)
       d1 = d2 = 0;

       ans = ans - (d1 + d2)*(d1 - d2 + 1)/2;
        //cout << ans << endl;
       ans = ans + even(down1, up1)*even(down2, up2);
        //cout << ans << endl;
       d1 = even(max(down2 + 2, down1), up1);
       d2 = even(max(up2 + 2, down1), up1);
       if(up2 == down2 && up2 % 2 == 1)
       d1 = d2 = 0;

       ans = ans - (d1 + d2)*(d1 - d2 + 1)/2;
       //cout << ans << endl;
       //cout << down2 << up1 << endl;
       a++;
       l--;
    }

    cout << ans << endl;
    return 0;
}

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

int func(int x,int y,int l)
{
    if(y>x)
    return 0;
    l=min(l,x-y);
    return (l+1)*(l+2)/2;
}

int main() {
    int a,b,c,l;
    cin>>a>>b>>c>>l;
    int ans=0;
    for(int i=0;i<=l;i++)
    {
        ans+=(i+1)*(i+2)/2;
        ans-=func(a+i,b+c,l-i);
        ans-=func(c+i,b+a,l-i);
        ans-=func(b+i,a+c,l-i);

    }
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

#define fi(a,b,c) for(long a=b;a<=c;a++)
#define fo(a,b,c) for(long a=b;a>=c;a--)
#define long long long

const long Base = 1e6+1;

long a, b, c, l, ans;

long T(long l, long r){
  if (r < l) return 0;
  return (r+l)*(r-l+1)/2;
}

void Solve(long a, long b, long c, long l){
  //2 7 8 4
  if (a+b > c && a+c > b && b+c > a) ans++;
  if (b+c+l <= a) return;
  int st = b+c > a ? 1:a+1-b-c;
  b = a-b; c = a-c;
  if (b > c) swap(b,c);
  if (b == c && b == 1)
    return;

  if (l < b){
    ans += T(st+1,l+1);
    return;
  }else
    ans += T(st+1,b);

  if (b == c)
    ans += b-1;
  else
    ans += b;

  if (l < c){
    ans += (l-b)*b;
    return;
  }else
    ans += (c-b-1)*b;

  if (b <= 1) return;
  ans += b-1;
  if (l < b+c-1){
    ans += T(b-l-1,b-2);
    return;
  }else
    ans += T(1,b-2);
}

void Equa_Two(long a, long b, long c, long l){
  fi(i,a,a+l){
    if (b > i || c > i) continue;
    int nwl = l-(i-a);
    if (b+nwl < i) break;
    nwl -= i-b;
    ans += i-c > nwl ? nwl+1:i-c;
  }
}

main(){
  cin >> a >> b >> c >> l;

  fi(i,0,l){
    if (a+i > b && a+i > c)
      Solve(a+i,b,c,l-i);
    if (b+i > a && b+i > c)
      Solve(b+i,a,c,l-i);
    if (c+i > a && c+i > b)
      Solve(c+i,b,a,l-i);
  }

  fi(i,a,a+l){
    if (b > i || c > i) continue;
    if (i*3 <= a+b+c+l)
      ans++;
    else
      break;
  }

  Equa_Two(a,b,c,l);
  Equa_Two(a,c,b,l);
  Equa_Two(b,c,a,l);

  cout << ans;
}

#include <bits/stdc++.h>

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define file ""
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> PII;

const int N = 2e5;
const int INF = 1e9 + 9;

int solo(int a, int b, int c, int l) {
	int ans = 0;
	forn(add, max(0, max(b, c) - a + 1), l) {
	    int na = a + add;
		int l2 = l - add;
		int b_lim = na - b - 1;
		int c_lim = na - c - 1;

		l2 = min(l2, b_lim + c_lim);
	    int low = max(0, na - b - c + 1);
		if (low > l2) continue;

	    forn(add_b, 0, min(b_lim, l2)) {
	    	if (low - add_b > c_lim) continue;
	    	ans += min(c_lim, l2 - add_b) - max(0, low - add_b) + 1;
	    }
	    //if (a == 5) cerr << add << " " << ans << "\n";
	}
	return ans;
}

int dbl(int a, int b, int c, int l) {
	int ans = 0;
	forn(nval, max(max(a, b), c + 1), INF) {
		int l1 = (nval - a) + (nval - b);
		if (l1 > l) return ans;
		ans += min(nval - c - 1, l - l1) + 1;
	}
	return ans;
}

int a, b, c, l;

int main () {
#ifdef machine42
	freopen (file"in", "r", stdin);
	freopen (file"out", "w", stdout);
#endif
	ios_base :: sync_with_stdio (0);
	cin.tie(0);

	cin >> a >> b >> c >> l;

	int ans = 0;
	///a - max
	ans += solo(a, b, c, l);
	///b - max
	ans += solo(b, a, c, l);
	///c - max
	ans += solo(c, a, b, l);
	//cerr << ans << "\n";
	///a, b - max
	ans += dbl(a, b, c, l);
	///a, c - max
	ans += dbl(a, c, b, l);
	///b, c - max
	ans += dbl(b, c, a, l);
	///eql
	forn(nval, max(a, max(b, c)), INF) {
		if (nval * 3 - a - b - c > l) break;
		++ans;
	}

	cout << ans << "\n";

	return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll solve(ll a,ll b,ll c,ll m)
{
    ll ret=min(a-b-c,m);
    if(ret<0)return 0;
    return (ret+2)*(ret+1)/2;
}
int main()
{
    ll ans=0;
    ll a,b,c,l;
    cin>>a>>b>>c>>l;
    for(int i=0;i<=l;i++){
        ans+=(i+2)*(i+1)/2;
    }
    for(int i=0;i<=l;i++){
        ans-=solve(a+i,b,c,l-i);
        ans-=solve(b+i,a,c,l-i);
        ans-=solve(c+i,a,b,l-i);
    }
    cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
long long a, b, c, A[5], l, ans;
int main () {
    ios_base::sync_with_stdio(0);
    scanf("%lld%lld%lld", &a, &b, &c, &l);
    for (int i = a; i <= a + l; i++) {
        for (int j = b; j <= b + l; j++) {
            for (int k = c; k <= c + l; k++) {
                if (k >= i + j) break;
                else
                if (j >= k + i) k += (j - (k + i));
                else
                if (i >= j + k) k += (i - (j + k));
                A[1] = i; A[2] = j; A[3] = k;
                sort(A + 1, A + 3 + 1);
                if (A[3] < A[1] + A[2] && (i + j + k) - (a + b + c) <= l) ans++;
            }
        }
    }
    printf("%llld", ans);
}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#define ll long long
using namespace std;
int n,m,len[4];
int main()
{
    for(int i=1;i<=3;++i) scanf("%d",&len[i]);
    scanf("%d",&m);
    sort(len+1,len+4);
    int cnt=0;
    if(len[3]<len[1]+len[2]) cnt=1;
    else if(len[3]>=(len[1]+len[2]+m)) {printf("0\n");return 0;}
    ll sum=0;
    for(int i=0;i<=m;++i)
        sum+=((i+1)*(1+1+i))/2;
    int p=len[1]+len[2]+len[3];
    for(int i=1;i<=3;++i){
        int tp=p-len[i];
        for(int j=max(tp-len[i],0);j<=m;++j){
            int tmp=min(m-j,len[i]+j-tp);
            sum-=(tmp+1+1)*(tmp+1)/2;
        }
    }
    printf("%I64d\n",sum);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MAXN ll(1e5)
#define INF  ll(1e17)
typedef long long ll;

ll sum[111111];

inline int get(ll a, ll b, ll c, ll l){
    ll x, ans = 0;
    if (a > b+c)
        x = a-b-c,
        ans += 2*sum[(l-x+2)/2]-sum[x+1]-(((l-x)/2+1)*((l-x)/2+2))/2;
    else
        x = b+c-a,
        ans += sum[((l-x)/2+1)]*2-(((l-x)/2+1)*((l-x)/2+2))/2;
    return ans;
}

ll a, b, c, l;
main () {
    cin >> a >> b >> c >> l;
    if (a+b+c+l <= max(a, max(b, c))*2){
        cout << 0;
        return 0;
    }
    for (ll i = 1; i <= l+1; ++i){
        sum[i] += sum[i-1]+i;
        ///cout << sum[i]<< " ";
    }
    ///cout << "\n";
    ll ans = get(a, b, c, l)+get(b, a, c, l)+get(c, b, a, l);
    cout << sum[l+1]-ans+1;
}

#include<bits/stdc++.h>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define MC(n,m) memcpy((n),(m),sizeof(n))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define FOR(x,y) for(__typeof(y.begin())x=y.begin();x!=y.end();x++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
// Let's Fight!

typedef long long ll;

const ll INF = 1E9;

ll rectangle(ll a, ll b, ll g, ll d, ll lim)
{
  // cout<<a<<","<<b<<","<<g<<","<<d<<endl;
  if(a>b || g>d) return 0;
  ll tot = (b-a+1) * (d-g+1);
  ll mc = a+g-lim;
  if(mc < 0) tot -= mc * mc;
  ll md = a-d;
  if(md < 0) tot -= md * md;
  return tot;
}

ll calc(ll a, ll b, ll c, ll l)
{
  ll alpha = a-b-c+1;
  ll beta = l;
  ll gamma = c-b-a+1;
  ll delta = c-b+a-1;

  delta = min(delta, l);
  gamma = max(gamma, -l);
  alpha = max(alpha, 0LL);
  alpha = max(alpha, gamma);
  alpha = max(alpha, -delta);

  if(alpha > beta || gamma > delta)
    return 0;

  ll g1 = (gamma+1+2*INF)/2 - INF, d1 = (delta+2*INF)/2 - INF;
  ll g2 = (gamma+2*INF)/2 - INF, d2 = (delta-1+2*INF)/2 - INF;

  // cout<<alpha<<"~"<<beta<<" "<<gamma<<"~"<<delta<<endl;

  ll tot = rectangle((alpha+1)/2, beta/2, g1, d1, 0);
  tot += rectangle(alpha/2, (beta-1)/2, g2, d2, -1);

  // cout<<a<<" "<<b<<" "<<c<<" "<<l<<" : "<<tot<<endl;
  return tot;
}

int main()
{
  IOS;

  ll a, b, c, l;
  cin>>a>>b>>c>>l;

  ll ans = 0;
  for(int i=0; i<=l; i++)
    ans += calc(a+i, b, c, l-i);

  cout<<ans<<endl;

  return 0;
}

// ntuj - j7s3dk07sfj6bmlpe9w13

#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 2000000
#define INF 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    a b c
    increase each stick, sum <= l
    can not increase any stick

    INPUT
        a b c l (a,b,c: 1->3e5, l: 0->3e5)
    OUPUT
        number of way increase

 Idea
    a+x + b+y <= c+z
        x, y => find how many z

    f(a,b,c,l)
        g(a,b,c+i, l-i)

    x, y, z
    x+y+z <= l
    a <= x < l/2
    b <= y < l/2
    c <= z < l/2

    f(x, y) = (|x-y| + 1, c)  (|x+y| - 1, l-x-y)
    f(x, y:1)

    x+y = u
    x: a->u-b
    |x-y| => |u - 2a| => |u-2b|

    x+y = u

    triangle
        range(max(c, |x-y| + 1), min(x+y-1, l-x-y))

    each x-y = d

    ways(u) ways(u) x,y,z x+y = u and satisfy conditions
        x: a => y = u-a  triangle(a,u-a)
        y:b => x = u-b   triangle(u-b,b)

        u-2 > z => ways(u-2, l-2)
        x-1, y-1 z

        z = u-1 <= l-u => range(a, u-b)
        z = u-2 <= l-u => range(max(a,2), min(u-b, u-2))

    ways(a+b) = triangle(a,b)
    ways(a+b+1) = triangle(a+1, b) + triangle(a, b+1);

    ways(u, l) = ways(u-2, l-2) + C;
    ans(l) = ways(a+b) + ways(a+b+1) + ans(l-2) + sum(C)

    g(l) = sum(ways(i, l)) 1:a+b->l

 Seond Idea
 ways(u) x+y+z <= l
    x = a || y = b
        x = a
            u[i] = u[i-1] + pair(i-a, a+1, b, c), i:1->l
        y = b
            v[i] = v[i-1] + pair(i-b, b+1, a, c), i:1->l
        x = a && y = b
            triangle(a, b)

    z = x+y-1
        2x+ 2y <= l + 1
        t[i]
            t[i-1] l odd
            t[i-1] + pair(i/2, INF, a, b)
            i: 1->l

    z = x+y-2
        2x + 2y <= l + 1    y[l]
        w[l]
            w[l-1] l even
            w[l-1] + pair((l+1)/2, INF, max(a,2), max(b,2))
            i: 1->l

    pair (sum, dif, a, b)
        range( max(ceil((sum-dif)/2.0), a), min((sum+dif)/2, sum-b))

 ways(i) = ways(i-2) + u[i] + v[i] - range(max(abs(a-b) + 1, c), min(a+b-1, i-a-b)) + t[i] + w[i]

    Complexity(O(N))

 Test
 */

int range(int x, int y){
    return max(y-x+1, 0);
}

int getPair(int sum, int dif, int a, int b){
    return range(max((int)ceil((sum-dif)/2.0), a), min((sum+dif)/2, sum-b));
}

ll u[N]{0}, v[N]{0}, w[N]{0}, t[N]{0}, ways[N]{0};

int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int a,b,c,l;
    cin >> a >> b >> c >> l;
    l = l + a + b + c;
    go(i,2,l){
        u[i] = u[i-1] + getPair(i-a, a+1, b, c);
        v[i] = v[i-1] + getPair(i-b, b+1, a, c);
        t[i] = t[i-1];
        if(i%2 == 0) t[i] += getPair(i/2, INF,  a, b);
        w[i] = w[i-1];
        if(i%2 == 1) w[i] += getPair((i+1)/2, INF, max(a,2), max(b,2));
        ways[i] = ways[i-2] + u[i] + v[i] - range(max(abs(a-b) + 1, c), min(a+b-1, i-a-b)) + t[i] + w[i];
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int check(int a, int b, int c, int r){
	if (b + c > a){
		return 0;
	}
	int d = min(r, a - b - c);
	return (d+2)*(d+1)/2;
}

int main(){
	int a, b, c, l;
	long long total;

	scanf("%d %d %d %d", &a, &b, &c, &l);

	total = (l+3)*(l+2)*(l+1)/6;

	for (int i=0; i<=l; i++){
		total -= check(a+i, b, c, l-i);
		total -= check(b+i, a, c, l-i);
		total -= check(c+i, a, b, l-i);
	}

	printf("%l64d\n", total);
}

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[3], l;
	cin >> a[0] >> a[1] >> a[2] >> l;

	int total = (l + 1) * (l + 2) * (l + 3) / 6;
	int perimeter = a[0] + a[1] + a[2];
	for (int i = 0; i < 3; i++)
	{
		int sides_length = perimeter - a[i];
		for (int extension = max(sides_length - a[i], 0); extension <= l; extension++)
		{
			int diff = min(l - extension, a[i] + extension - sides_length);
			total -= (diff + 1) * (diff + 2) / 2;
		}
	}

	cout << total;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;

ll Count(int a, int b, int c, int lft){
	if(a < b + c) return 0;
	ll t = min(lft, a - (b + c));
	return (t + 1LL) * (t + 2LL) / 2LL;
}

int main(){
	freopen("in.txt", "r", stdin);
	int a, b, c, l;
	while(scanf("%d%d%d%d", &a, &b, &c, &l) != EOF){
		ll ans = (l + 1) * (l + 2) * (l + 3) / 6;
		for(int i = 0; i <= l; i++){
			ans -= Count(a + i, b, c, l - i) + Count(b + i, a, c, l - i) + Count(c + i, a, b, l - i);
		}
		printf("%I64d\n", ans);
	}
	return 0;
}
/*
1 50
B 47828 7726

*/

#include <iostream>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <cstdlib>
using namespace std;
int solve(int a,int b,int c,int l)
{
	int ans;
	if(a<b+c)return 0;
	if(a-b-c<l)
	{
		ans=a-b-c;
	}
	else
	{
		ans=l;
	}
	cout<<a-b-c<<" "<<l<<" "<<ans<<endl;
	return (ans+1)*(ans+2)/2;
}
int main()
{
	int sum,a[3],l;
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
	}
	cin>>l;
	sum=((l+3)*(l+2)*(l+1))/6;
	for(int i=0;i<=l;i++)
	{
		sum-=solve(a[1]+i,a[2],a[3],l-i);
		sum-=solve(a[2]+i,a[3],a[1],l-i);
		sum-=solve(a[3]+i,a[1],a[2],l-i);
	}
	cout<<sum<<endl;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int l;
  vector<int> v(3,0);
  cin>>v[0]>>v[1]>>v[2];
  cin>>l;
  sort(v.begin(),v.end());
  long long  n= (l+1);
  n=n*(l+2);
  n=n*(l+3);
  n=n/6;
  long long resp=0;
  for(int la=0;la<=l;la++)
  {
    long long x= min(v[2]-v[1]-v[0]+la,l-la);
    if(x>0)
    {
    long long a=((x+1)*(x+2));
    a=a/2;
    resp+=a;
    }
  }
  int cont=1;
  for(int i=0;i<2;i++)
  {
    if(v[i]==v[2]) cont++;
  }
  if(v[1]==v[0]) cont++;
  resp=resp*cont;
  cout<<n-resp<<endl;

  return 0;
}

//容斥原理：总方案数-不构成三角形的方案数
//L个求 放到4个盒子里C(L+3, 3)-->L+3的位置放3块隔板
//L个球 选i=0 to L放到三个盒子里sigma C(L+2, 2)
//枚举最长边假设a+i为最长边
//i = b + c - a to L
//对于这个i的方案数应为a+i为最长边的方案数，既能给b,c的最长的木棍长度x=min(a+i-b-c,L-i)C(x+2,2)
#include<iostream>
using namespace std;
int a, b, c, l, ans;
long long work(int a, int b, int c, int l){ // 以a+i为最长边
	long long ret = 0;
	for (int i = b+c-a; i <= l; i++){
		long long x = min(a+i-b-c, l-i);
		ret += (x+1) * (x+2) / 2;
	}
	return ret;
}
int main(){
	cin >> a >> b >> c >> l;
	//C(n,3) = n!/3!/(n-3)! --> n*(n-1)*(n-2)/6
	ans = (l + 3) * (l + 1) * (l + 2) / 6;
	ans -= work(a,b,c,l);
	ans -= work(b,a,c,l);
	ans -= work(c,a,b,l);
	cout << max(0, ans) << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int bad(int a,int b,int c,int l)
{
	long long rel=min(a-b-c,l);
	if(rel<0) return 0;
	else return (rel+2)*(rel+1)/2;
}
int main()
{
	int a,b,c,l;
	long long tol;
	cin>>a>>b>>c>>l;
	tol=(l+1)*(l+2)*(l+3)/6;
	for(int i=0;i<=l;i++)
	{
		tol-=bad(a+i,b,c,l-i);
		tol-=bad(b+i,a,c,l-i);
		tol-=bad(c+i,a,b,l-i);
	}
	cout<<tol<<"\n";
	return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

#define F first
#define S second
#define eps 1e-8
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define INF 2000000000

typedef long long ll;

using namespace std;
ll ans;
void func(int a, int b, int c, int l){
	int cur = max(a, max(b, c)), x, y, z, t, r;
	l -= cur - a;
	a = cur;
	if(a == b || a == c)
		a++, l--;
	if(l >= 0){
		for(int i = 0; i <= l; i++){
			cur = l - i;
			x = a - b - 1;
			y = a - c - 1;
			if(x < 0 || y < 0 || (b + c + min(x + y, cur) <= a))
				break;
			x = min(x, cur);
			y = min(y, cur);
			if(b + c > a){
//				ans += max(min(cur, y) - cur + x + 1, 0);
				for(int j = 0; j <= cur; j++)
					ans += max(min(j, y) - j + x + 1, 0);
			}
			else{
				z = a - b - c + 1;
				if(x + y >= z){
					t = min(cur - y, x);
					r = min(z, t);
					ans += (y - z + 1) * 1ll * (r + 1) + r * 1ll * (r + 1) / 2ll;
					ans += (y + 1ll) * 1ll * (t - r);
					t = max(cur - y, z) + 1;
					r = min(t, x);
					if(r >= t){
						ans += (r - t + 1) * 1ll * (1 + cur);
						t--;
						ans -= r * 1ll * (r + 1ll) / 2ll;
						ans += t * 1ll * (t + 1ll) / 2ll;
					}
					if(cur - y + 1 <= min(z, x)){
						t = min(z, x);
						r = cur - y + 1;
						ans += (cur - z + 1) * 1ll * (t - r + 1);
					}
				}
			}
			a++;
		}
	}
}
void Func(int a, int b, int c, int l){
	int cur = max(a, max(b, c)), x;
	l -= cur - a;
	a = cur;
	l -= cur - b;
	b = cur;
	if(a == c)
		a++, b++, l -= 2;
	if(l >= 0){
	    for(int i = 0; i <= l; i += 2){
	    	cur = l - i;
			x = min(a - c - 1, cur);
			ans += x + 1;
	    	a++, b++;
	    }
	}
}
int main()
{
	ios::sync_with_stdio(0);
	int a[9], l;
	cin >> a[0] >> a[1] >> a[2] >> l;
	func(a[0], a[1], a[2], l);
	func(a[1], a[0], a[2], l);
	func(a[2], a[1], a[0], l);
	Func(a[0], a[1], a[2], l);
	Func(a[0], a[2], a[1], l);
	Func(a[2], a[1], a[0], l);
	sort(a, a + 3);
	int x = 0;
	x = a[2] - a[0] + a[2] - a[1];
	if(l >= x){
		l -= x;
		ans += l / 3 + 1;
	}

	cout << ans;
	return 0;
}

#include <cmath>
#include <cstdio>
#include <string>
#include <iomanip>
#include <iostream>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

bool check(ll a, ll b, ll c){
    return (a+b) > c && (a+c) > b && (b+c) > a;
}

ll add_one(ll a, ll b, ll c, ll l){
    ll min_step = max(a+1, max(b-c, c-b)+1);
    ll max_step = min(b+c-1, a+l);
    ll ans = max_step - min_step + 1;
    return ans > 0 ? ans : 0;
}

ll add_two(ll a, ll b, ll c, ll l){
    int ans = 0;
    for(int y = 1; y < l; y++)
        ans += add_one(a, b+y, c, l-y);
    return ans;
}

ll add_one_sp(ll a, ll b, ll c, ll l){
    ll min_step = max(a+1, max(b-c, c-b)+1) - a;
    ll max_step = min(b+c-1, a+l) - a;

    ll ans = 0;
    int lb, ub;
    for(lb = min_step; lb <= max_step && (l-lb) % 3 != 2; lb++)
        ans += (l-lb)/3 + 1;
    for(ub = max_step; ub >= lb && (l-ub) % 3 != 0; ub--)
        ans += (l-ub)/3 + 1;
    if(ub > lb){
        int maxv = (l - lb)/3 + 1;
        int minv = (l - ub)/3 + 1;
        ans += 3 * (maxv+ minv) * (maxv- minv+1)/2;
    }
    return ans;
}

ll add_three(ll a, ll b, ll c, ll l){
    int ans = 0;
    for(int y = 1; y < l; y++)
        ans += add_one_sp(a, b+y, c, l-y);
    return ans;
}

int main(){
    ios::sync_with_stdio(false);

    ll a, b, c, l;
    cin >> a >> b >> c >> l;
    ll ans = 0;

    if(check(a, b, c))
        ans = l / 3 + 1;
    ans += add_one_sp(a, b, c, l);
    ans += add_one_sp(b, c, a, l);
    ans += add_one_sp(c, a, b, l);
    ans += add_three(a, b, c, l);
    ans += add_three(b, c, a, l);
    ans += add_three(c, a, b, l);

//    for(int x = 0; x <= l; x++)
//        for(int y = 0; y <= l-x; y++)
//            ans += add_one(a, b+x, c+y, l - x - y);

    cout << ans << endl;

    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans,tmp;
int i,j,k,n,m,a,b,c;
ll calc(ll a,ll b,ll n){
	if (a+b<=n) return (a+1)*(b+1);
	if (b>n) return (n+2)*(n+1)/2;else return (b+2)*(b+1)/2;
}
void work(){
	int t1,t2,i,j,k,lim;
	k=max(a,max(b,c));
	for (i=k;i<=a+n;i++){
		j=n-(i-a);
		if (b+c+j<=i) continue;
		t1=min(i-b,j);t2=min(i-c,j);lim=i-b-c+1;
		if (t1<t2) swap(t1,t2);
		ans+=calc(t1,t2,j);
		if (lim) ans-=calc(t1,t2,lim-1);
	}
}
void work2(){
	int i,k;
	k=max(a,max(b,c));
	for (i=k;i-a+i-b<=n;i++){
		k=n-(i-a+i-b);
		tmp+=1+min(i-c,k);
	}
}
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&n);
	ans=0;
	work();
	swap(a,b);
	work();
	swap(a,c);
	work();
	tmp=0;
	work2();
	swap(b,c);
	work2();
	swap(a,c);
	work2();
	ans-=tmp;
	for (i=max(a,max(b,c));3*i-a-b-c<=n;i++) ans++;
	printf("%I64d\n",ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll linf = 1e18 + 9;
const int N = 1e5 + 9;

ll a, b, c, l;

ll con(ll x, ll y, ll z, ll cm) {
	ll temp = min(min(x - y - z, l - (x - cm)), linf * !(x < y + z));
	return (temp + 1) * (temp + 2) / 2;
}

int main() {

	cin >> a >> b >> c >> l;

	ll ans = (l + 3) * (l + 2) * (l + 1) / 6;

	for (ll i = 1; i <= l; i++) {
		ans -= con(a + i, b, c, a) + con(b + i, a, c, b) + con(c + i, a, b, c);
	}

	if (ans < 0) cout << 0 << endl;
	else cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MAXN ll(1e5)
#define INF  ll(1e17)
typedef long long ll;

ll sum[111111], ZOM[1111111];

inline int get(ll a, ll b, ll c, ll l){
    ll x, ans = 0, F = b+c-a;
    if (a < c+b)
        a+=F, l-=F;

    x = a-b-c;

    if (a == b+c)
        ans += 2*ZOM[(l+2)/2];
    else
        ans += 2*ZOM[(l-x+2)/2]-ZOM[x+1];
    if(l%2==0) ans-=sum[(l-x)/2+1];
    return ans;
}

ll a, b, c, l;
main () {
    cin >> a >> b >> c >> l;
    if (a+b+c+l <= max(a, max(b, c))*2){
        cout << 0;
        return 0;
    }

    for (ll i = 1; i <= l+1; ++i){
        sum[i] += sum[i-1]+i;
        ZOM[i] += sum[i]+ZOM[i-1];
    }
    ll ans = get(a, b, c, l)+get(b, a, c, l)+get(c, b, a, l);
    cout << ZOM[l+1]-ans;
}

#include<bits/stdc++.h>
using namespace std;
long long a,b,c,l,ans;
void did(long long lastlen){
	cout<<lastlen<<endl;
	ans=ans-(lastlen+2)*(lastlen+1)/2;
}
int main(){
	cin>>a>>b>>c>>l;
	ans=(l+3)*(l+2)*(l+1)/6;
	if(max(a,max(b,c))*2>=a+b+c+l){
		cout<<0;
		return 0;
	}
	for(int i=0;i<=l;i++){
		if(a+i>=b+c)did(l-(a+b+c+l+1)/2+a);
		if(b+i>=a+c)did(l-(a+b+c+l+1)/2+b);
		if(c+i>=a+b)did(l-(a+b+c+l+1)/2+c);
	}
	cout<<ans;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,l;
ll ans=0;
ll count(ll x,ll y,ll z,ll len)
{
	ll ret=0;
	for(int i=max((ll)(0),x+y-z);i<=len;i++)
	{
		ll now=min(len-i,z+i-x-y);
		ret=ret+(now+1)*(now+2)/2;//ret=ret+C(now+2,2);
	}
	return ret;
}

int main()
{
	scanf("%lld%lld%lld%d",&a,&b,&c,&l);
	ans++;
	for(int i=1;i<=l;i++) ans=ans+(i+1)*(i+2)/2;//ans=ans+C(i+2,2);
	ans-=count(a,b,c,l);
	ans-=count(a,c,b,l);
	ans-=count(c,b,a,l);
	printf("%lld",ans);
	return 0;
}

//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
void SR(int &x){scanf("%d",&x);}
void SR(ll &x){scanf("%lld",&x);}
void SR(double &x){scanf("%lf",&x);}
void SR(char *s){scanf("%s",s);}
void RI(){}
template<typename I,typename... T> void RI(I &x,T&... tail){SR(x);RI(tail...);}
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define pb push_back
#define mkp make_pair
//}}}
ll a,b,c,l;
void read()
{
	RI(a,b,c,l);
}
void build()
{
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);
}
ll C(ll x,ll y)
{
	if(x<y) return 0;
	if(y<0) return 0;
	if(x<0) return 0;
	ll ans=1;
	REP(i,y) ans*=(x-i);
	REP(i,y) ans/=(i+1);
	return ans;
}
ll H(ll x,ll y)
{
	return C(x+y-1,y);
}
void sol()
{
	ll ans=0;

	REP1(len,c,c+l)
	{
		int rst=l+c-len;
		if(len<=max(a,b)) continue;
		ll tmp=H(3,rst)-H(3,len-a-b)-H(3,rst-(len-a-1))-H(3,rst-(len-b-1));
		if(tmp>0) ans+=tmp;
		//printf("%d %lld %lld %lld %lld\n",len,H(3,rst),H(3,len-a-b),H(3,rst-(len-a)),H(3,rst-(len-b)));
	}
	swap(b,c);
	REP1(len,c,c+l)
	{
		int rst=l+c-len;
		if(len<=max(a,b)) continue;
		ll tmp=H(3,rst)-H(3,len-a-b)-H(3,rst-(len-a-1))-H(3,rst-(len-b-1));
		if(tmp>0) ans+=tmp;
		//printf("%d %lld %lld %lld %lld\n",len,H(3,rst),H(3,len-a-b),H(3,rst-(len-a-1)),H(3,rst-(len-b-1)));
	}
	swap(a,c);
	REP1(len,c,c+l)
	{
		int rst=l+c-len;
		if(len<=max(a,b)) continue;
		ll tmp=H(3,rst)-H(3,len-a-b)-H(3,rst-(len-a-1))-H(3,rst-(len-b-1));
		if(tmp>0) ans+=tmp;
		//rintf("%d %lld %lld %lld %lld\n",len,H(3,rst),H(3,len-a-b),H(3,rst-(len-a-1)),H(3,rst-(len-b-1)));
	}
	//printf("%lld %lld %lld\n",a,b,c);
	REP1(sid,max(a,b),max(a,b)+l)
	{
		int rst=l-(sid-a)-(sid-b);
		if(rst<0) break;
		if(c>2*sid-1) continue;
		ans+=min(2*sid-c,rst+1LL);
		if(c<=sid&&sid<=c+rst) ans--;
		//printf("%d %lld,",rst,ans);
	}//printf("%lld\n",ans);
	swap(b,c);
	REP1(sid,max(a,b),max(a,b)+l)
	{
		int rst=l-(sid-a)-(sid-b);
		if(rst<0) break;
		if(c>2*sid-1) continue;
		ans+=min(2*sid-c,rst+1LL);
		if(c<=sid&&sid<=c+rst) ans--;//printf("%d %lld,",rst,ans);
	}//printf("%lld\n",ans);
	swap(a,c);
	REP1(sid,max(a,b),max(a,b)+l)
	{
		int rst=l-(sid-a)-(sid-b);
		if(rst<0) break;
		if(c>2*sid-1) continue;
		ans+=min(2*sid-c,rst+1LL);
		if(c<=sid&&sid<=c+rst) ans--;//printf("%d %lld,",rst,ans);
	}//printf("%lld\n",ans);

	REP1(sid,max(max(a,b),c),max(max(a,b),c))
	{
		int rst=l-(sid-a)-(sid-b)-(sid-c);
		if(rst<0) break;
		ans++;
	}
	printf("%lld\n",ans);
}
int main()
{
	read();
	build();
	sol();
	return 0;
}

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define FOREACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)

#define MOD 1000000007
#define INF 2000000000

LL a, b, c, l;

LL solve1(LL x, LL y, LL z) {
    LL start = (x > y && x > z) ? x : max(y, z) + 1;
    LL res = 0;

    LL maxay = (start - 1) - y;
    LL maxaz = (start - 1) - z;

    for (LL nx = start; nx <= start + l; nx++) {
        LL left = l - (nx - x); if (left < 0) break;
        LL need = (nx + 1) - (y + z); if (need > left) break;
        LL window = left - need + 1;

        LL yl = max(need - maxaz, 0LL); // first possible window start
        LL yr = maxay - window + 1;     //  last possible window start

        LL ztmp = maxaz + 1;

        if (yl > maxay) {
            maxay++;
            maxaz++;
            continue;
        }

        if (yl <= yr) {
            res += min(ztmp, yr - yl + 1) * window;
            ztmp -= min(ztmp, yr - yl + 1);
            yr++;
        }
        else {
            yr = yl;
        }

        LL yhi = max(0LL, maxay - yr + 1);
        LL ylo = max(0LL, yhi - ztmp);

        res += yhi * (yhi + 1) / 2 - ylo * (ylo + 1) / 2;

        maxay++;
        maxaz++;
    }

    return res;
}

LL solve2(LL x, LL y, LL z) {
    LL start = (x > z || y > z) ? max(x, y) : z + 1;
    LL res = 0;

    for (LL nx = start; nx <= start + l; nx++) {
        LL left = l - (nx - x) - (nx - y); if (left < 0) break;
        res += min(nx - 1, z + left) - z + 1;
    }

    return res;
}

LL solve3(LL x, LL y, LL z) {
    LL start = max(x, max(y, z));
    LL res = 0;

    for (LL nx = start; nx <= start + l; nx++) {
        LL left = l - (nx - x) - (nx - y) - (nx - z); if (left < 0) break;
        res += 1;
    }

    return res;
}

int main() {
    cin >> a >> b >> c >> l;

    LL res = 0;

    res += solve1(a, b, c);
    res += solve1(b, c, a);
    res += solve1(c, a, b);
    res += solve2(a, b, c);
    res += solve2(a, c, b);
    res += solve2(b, c, a);
    res += solve3(a, b, c);

    cout << res << endl;
    return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,c,l,A,B,C,ans;
main(){
  scanf("%d%d%d%d",&a,&b,&c,&l);
  l-=(!a+!b+!c);
  a+=!a;
  b+=!b;
  c+=!c;
  for(long long i=0;i<=l;i++)
    A=max(min(l-i,a+i-b-c),-1ll)+2,B=max(min(l-i,b+i-a-c),-1ll)+2,C=max(min(l-i,c+i-b-a),-1ll)+2,
      ans-=A*(A-1)+B*(B-1)+C*(C-1);
  printf("%d",(ans/2+((l+3)*(l+2)*(l+1))/6)*(l>=0));
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MAXN ll(1e5)
#define INF  ll(1e17)
typedef long long ll;

ll sum[111111], ZOM[1111111];

inline ll get(ll a, ll b, ll c, ll l){
    ll x, ans = 0, F = b+c-a;
    if (a < c+b)
        a+=F, l-=F;

    x = a-b-c;

    if (a == b+c)
        ans += 2*ZOM[(l+2)/2];
    else{
        ans += 2*ZOM[(l-x+2)/2]-ZOM[x+1];
    }
    if(l%2==0) ans+=sum[(l-x)/2+1];
    return ans;
}

ll a, b, c, l;
main () {
    cin >> a >> b >> c >> l;
    if (a+b+c+l <= max(a, max(b, c))*2){
        cout << 0;
        return 0;
    }

    for (ll i = 1; i <= l+1; ++i){
        sum[i] += sum[i-1]+i;
        ZOM[i] += sum[i]+ZOM[i-1];
    }

    ll ans = get(a, b, c, l)+get(b, a, c, l)+get(c, b, a, l);

    cout << ZOM[l+1]-ans;
}

    #include<bits/stdc++.h>
    // #include<ext/pb_ds/assoc_container.hpp>
    // #include<ext/pb_ds/tree_policy.hpp>
using namespace std;
        // using namespace __gnu_pbds;

typedef long long int lli;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii>vpii;
typedef std::vector<lli> vll;
typedef std::vector<pll> vpll;
typedef std::vector<bool> vbb;
typedef map<lli,lli>mll;
typedef set<lli> sll;
typedef multiset<lli> msll;
lli MOD=1e9 +7;
lli INF=9e18;

    #define forr(i,p,n) for(i=p; i<n; i++)
    #define forn(i,p,n) for(i=p; i<=n; i++)
    #define forl(i,n,p) for(i=n; i>=p; i--)
    #define be(a) a.begin(),a.end()
    #define mp make_pair
    #define eb emplace_back
    #define pb push_back
    #define F first
    #define S second
    #define all(a)     (a).begin(),(a).end()
    #define PI 3.14159265358979323846
    #define lb lower_bound
    #define ub upper_bound
    #define endl "\n"
    #define bpcl(x) __builtin_popcountll(x)
    #define deb(vari) cerr<<#vari<<" = "<<vari<<endl;
                // #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
lli power(lli base, lli exp) {lli res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
lli bitc(lli n,lli x){return ((n>>x)&1);}
lli __gcd(lli a,lli b){return b==0?a:__gcd(b,a%b);}
lli fsub(lli a,lli b,lli p=MOD){return ((a%p)-(b%p)+p)%p;}
lli fmult(lli a,lli b, lli p=MOD) {return ((a%p)*(b%p))%p;}
lli fadd(lli a, lli b, lli p=MOD) {return (a%p + b%p)%p;}
                                        // lli add(lli a,lli b,lli p=MOD){//if(a+b>=p){//return (a+b)-p;//  }//return a+b;// }
lli fpow(lli n, lli k, lli p = MOD) {lli r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
lli inv(lli a, lli p = MOD) {return fpow(a, p - 2, p);}
lli fdiv(lli a,lli b,lli p=MOD){lli yinv=inv(b);lli ans=(a*yinv)%p;return ans;}

    template<typename T>istream &operator>>(istream &in, vector<T> &a) {for (auto &item : a) {in >> item;}return in;}template<typename T,typename U>ostream &operator<<(ostream &out, pair<T,U> &a) {cout<<a.F<<" "<<a.S;return out;}
    template<typename T,typename U>
istream &operator>>(istream &out, pair<T,U> &a) {cin>>a.F>>a.S;return out;}
    template<typename T,typename U>
ostream &operator<<(ostream &out, map<T,U> &a) {for (auto &item : a) {out << item << endl;}return out;}
    template<typename T>
ostream &operator<<(ostream &out, vector<T> &a) {for (auto &item : a) {out << item << " ";}return out;}
    template<typename T>
ostream &operator<<(ostream &out, vector<vector<T>> &a) {for (auto &item : a) {out << item << "\n";}return out;}
    template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
    static_assert(D >= 1, "Vector dimension must be greater than zero!");
                          template<typename... Args>
    Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
    }
};
    template<typename T>
struct Vec<1, T> : public vector<T> {
    Vec(int n = 0, T val = T()) : vector<T>(n, val) {
    }
};
                    // Vec<2,lli>mat(n,n,1);
    #define print(a) for(auto p:a) cout<<p<<endl; cout<<endl;
    #define read(a) for(auto &p:a)cin>>p>>endl;
std::vector<bool> is_prime;
std::vector<lli> primes;
void sieve(lli n){is_prime.resize(n+2,true);primes.clear();lli p;for(p=2;p*p<=n;p++){if(is_prime[p]){lli i;for(i=p*p;i<=n;i+=p){is_prime[i]=false;}}}is_prime[0]=is_prime[1]=false;lli i;for(i=2;i<=n;i++){if(is_prime[i]){primes.eb(i);}}}
mll prime_factors(lli n){  mll s;lli i;lli tc=0;while(n%2==0){tc++;n/=2;}if(tc>0){s[2]=tc;}for(i=3;i<=sqrt(n);i+=2){tc=0;while(n%i==0){tc++;n/=i;}if(tc>0){s[i]=tc;}}if(n>2){s[n]+=1;}return s;}
std::vector<lli> fact_vec;
void fact_fun(lli n){fact_vec.resize(n+10);lli i;fact_vec[0]=1;for(i=1;i<=n+2;i++){fact_vec[i]=(fact_vec[i-1]*i)%MOD;}}
vll p2;
void power_2(lli n,lli m=MOD){ lli i;MOD=m;p2.eb(1);forr(i,0,n){p2.eb(fmult(p2.back(),2));}}
lli ncr(lli n,lli r){if(r>n)return 0;return fdiv(fact_vec[n],fmult(fact_vec[r],fact_vec[n-r]));}
vll spf;void sieve2(lli MAXN) { MAXN+=10;spf.resize(MAXN,0);spf[1] = 1; for (lli i=2; i<MAXN; i++) spf[i] = i;     for (lli i=4; i<MAXN; i+=2) spf[i] = 2; for (lli i=3; i*i<MAXN; i++) {         if (spf[i] == i) { for (lli j=i*i; j<MAXN; j+=i) {if (spf[j]==j) spf[j] = i; }} } }
const int mi[4]={-1, 0, 1, 0}, mj[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
mll getFactorization(lli x)
{
    mll ret;
    while (x != 1){
        // ret.eb(spf[x]);
        ret[spf[x]]++;
        x = x / spf[x];
    } return ret;
}

// class Sol{
// public:
//     Sol(){
//         lli  i,j;
//     }
// };
lli solve(lli a,lli b,lli c,lli l){
    lli i;
    lli ans=0;
    forn(i,0,l){
        lli na=a+l;
        if(na>= b+c){
            lli x=min(l-i,a+i-(b+c));
            ans+= ((x+1)*(x+2))/2;

        }
    }
    return ans;

}

int main(){
    lli i,j;

            #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt",  "w", stdout);
            #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    lli ti;

    ti=1;
        // cin>>ti;
    while(ti--){
        lli a,b,c,l;
        cin>>a>>b>>c>>l;
        lli ans= ((l+1)*(l+2)*(l+3))/6;
        // cout<<ans<<endl;
        ans-= solve(a,b,c,l);
        ans-= solve(b,a,c,l);
        ans-= solve(c,b,a,l);
        cout<<ans<<endl;
    }

}

#include<bits/stdc++.h>
using namespace std;
int cmp(int z,int x,int y,int p)
{
    if(p+z<x+y)return 0;
    int u=min(p,(p+z-x-y)/2);
    return (u+1)*(u+2)/2;
}
int main()
{
    int a,b,c,l;cin>>a>>b>>c>>l;int r=0;
    for(int i=0;i<=l;i++)
    {
        r+=(l-i+1)*(l-i+2)/2;
    }
    //cout<<r<<endl;

    for(int i=0;i<=l;i++)
        {r-=cmp(a,b,c,i);
        r-=cmp(b,c,a,i);r-=cmp(c,a,b,i);}
    cout<<r;

    return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

long long a,b,c,l,ans;

int check(int a,int b,int c)
{
	return a<b+c&&b<a+c&&c<a+b;
}

int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&l);
	if(check(a,b,c)) ans=1;
	for(long long i=1;i<=l;i++)
	{
		long long ttt=(a+b+c+i+1)>>1;
		long long k=i+2;
		ans+=k*(k-1)/2;
		ans-=max((i-ttt+a+1)*(i-ttt+a+2)/2,0ll);
		ans-=max((i-ttt+b+1)*(i-ttt+b+2)/2,0ll);
		ans-=max((i-ttt+c+1)*(i-ttt+c+2)/2,0ll);
	}
	printf("%lld\n",ans>0?ans:0ll);
}

#include<iostream>
using namespace std;
#define ull  long long
ull a,b,c;
ull l;
ull ans;
ull jc(ull x)
{
	int ans=1;
	for(ull i=1;i<=x;i++)
	{
		ans*=i;
	}
	return ans;
}
ull C(ull n,ull m)
{
	if(n<m)return 0;
	return jc(n)/(jc(n-m)*jc(m));
}
ull slove(ull a1,ull b1,ull c1)
{
	for(int i=max((ull)0,a1+b1-c1);i<=l;i++)
	{
		ull now=min(l-i,c1+i-a1-b1);
		ans-=C(now+2,2);
	}
}
int main()
{
	cin>>a>>b>>c>>l;
	ans=C(l+3,3);
	slove(a,b,c);
	slove(a,c,b);
	slove(b,c,a);
	cout<<ans<<endl;
}

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>

const int N = 3e5 + 10;

int a, b, c, l;

void init() {
    std::cin >> a >> b >> c >> l;
}

void work() {
    int answer = (l + 1) * (l + 2) * (l + 3) / 6;
    for (int x = 0; x <= l; x ++) {
        int tmp;
        tmp = std::min(a + x - b - c, l - x);
        if (tmp >= 0) {
            answer -= (tmp + 1) * (tmp + 2) / 2;
        }
        tmp = std::min(b + x - a - c, l - x);
        if (tmp >= 0) {
            answer -= (tmp + 1) * (tmp + 2) / 2;
        }
        tmp = std::min(c + x - b - a, l - x);
        if (tmp >= 0) {
            answer -= (tmp + 1) * (tmp + 2) / 2;
        }
    }
    std::cout << answer << std::endl;
}

int main() {
    //freopen("A.in", "r", stdin);

    init();
    work();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
long long a, b, c, A[5], l, ans;
int main () {
    ios_base::sync_with_stdio(0);
    cin >> a >> b >> c >> l;
    for (int i = a; i <= a + l; i++) {
        for (int j = b; j <= b + l; j++) {
            for (int k = c; k <= c + l; k++) {
                A[1] = i; A[2] = j; A[3] = k;
                sort(A + 1, A + 3 + 1);
                if (A[3] < A[1] + A[2] && (i + j + k) - (a + b + c) <= l) ans++;
                if (k >= i + j) k = c + l;
                else
                if (j >= k + i) k = j;
                else
                if (i >= j + k) k = i;
            }
        }
    }
    cout << ans;
}

#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct greater1
{
      template<class T>
      bool operator()(T const &a, T const &b) const { return a > b; }
};

struct smaller1
{
      template<class T>
      bool operator()(T const &a, T const &b) const { return a < b; }
};

void sochet(int n, int k, int pred, vector<int> mas){
      if (k == 0){
            for (int i = 0; i < mas.size(); i++)
                  cout << mas[i] << " ";
            cout << endl;
      }
      else{
            for (int i = pred; i <= n; i++){//i = pred + 1 sochetania bez povtorenii
                  mas[k-1] = i;
                  sochet(n, k - 1, i, mas);
            }
      }
}
void perest(int n, int k, vector<int> mas, vector<int> isp){
      if (isp.size() == 0){
            for (int i = 0; i < mas.size(); i++)
                  cout << mas[i] << " ";
            cout << endl;
      }
      else{
            for (int i = 0; i < isp.size(); i++){
                  mas[k] = isp[i];
                  vector <int> kaka = isp;
                  kaka.erase(kaka.begin() + i);
                  perest(n, k+1, mas, kaka);
            }
      }
}

bool pairCompare1(const std::pair<int, int>& firstElem, const std::pair<int, int>& secondElem) {
      return firstElem.first < secondElem.first;

}

bool pairCompare2(const std::pair<int, int>& firstElem, const std::pair<int, int>& secondElem) {
      return firstElem.first > secondElem.first;

}
void chislo(int a, int b, int c, int l, int &k, int pos){
      if ((a < (b + c)) && (b < (a + c)) && (c < (a + b))){
            k = k + 1;
            if (l > 0){
                  if (pos == 1){
                        chislo(a + 1, b, c, l - 1, k, 1);
                        chislo(a, b + 1, c, l - 1, k, 2);
                        chislo(a, b, c + 1, l - 1, k, 3);
                  }
                  if (pos == 2){
                        chislo(a, b + 1, c, l - 1, k, 2);
                        chislo(a, b, c + 1, l - 1, k, 3);
                  }
                  if (pos == 3){
                        chislo(a, b, c + 1, l - 1, k, 3);
                  }
            }
      }
      if (a == (b + c)) {
            if (l >= 1){
                  chislo(a, b + 1, c, l - 1, k, 2);
            }
            if (l >= 3){
                  chislo(a + 1, b + 1, c + 1, l - 3, k, 2);
            }
      }
      if (b == (a + c)) {
            if (l >= 1){
                  chislo(a + 1, b, c, l - 1, k, 1);
            }
            if (l >= 3){
                  chislo(a + 1, b + 1, c + 1, l - 3, k, 2);
            }
      }
      if (c == (a + b)) {
            if (l >= 1){
                  chislo(a + 1, b, c, l - 1, k, 1);
            }
            if (l >= 3){
                  chislo(a + 1, b + 1, c + 1, l - 3, k, 2);
            }
      }

}

int main() {
      int a, b, c, l;
      int aa, bb, cc;
      cin >> a >> b >> c >> l;
      int k = 0;
      int pos = 1;
      chislo(a, b, c, l, k, pos);
      cout << k;
      return 0;
}

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

#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define ldb long double
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define speed ios::sync_with_stdio(false)
#define FILL(x,i) memset(x, i, sizeof x)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second

const long long INF = 1e18, mod = 1e9 + 7, N = 1e5 + 9;

typedef pair <int,int> ii;
typedef vector <ii> vii;
typedef vector<int> vi;

int n, k;
ll a[300001], dp[5001][5001];
int main() {
    speed;
    cin >> n >> k;
    FILL(a, 0);
    fo(i, 1, n + 1) cin >> a[i];
    sort(a + 1, a + n + 1);
    ll l = n / k;
    dp[0][0] = 0;
    fo(i, 1, k + 1)
        fo(j, 0, min(n % k, i) + 1) {
            dp[i][j] = min( ( (j > 0) ? dp[i - 1][j - 1] - a[i * l + j - l] + a[i * l + j] : INF) , ((i - 1 >= j) ? dp[i - 1][j] - a[i * l - l + j + 1] + a[i * l + j] : INF));
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    cout << dp[k][n % k] << "\n";
}

//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

LL a, b, c, l;
LL ans = 0;

int main()
{
    cin>>a>>b>>c>>l;
    For(i,0,l+1)
    {
        LL A=a+i, B=min(b,c), C=max(b,c), L=l-i, ans2=0;
        ans2+=(l-i+1)*(l-i+2)/2;
        //cout<<ans2<<" ";
        if (A>=B+C)
        {
            ans2-=(A-B-C+1)*(A-B-C+2)/2;
        }
        if (B+L>=A+C)
        {
            L++;
            LL z=B+L-A-C;
            if (z<=L)
            {
                LL w=z/2;
                ans2-=w*(w+1);
                if (z%2==1) ans2-=(z+1)/2;
            }
            else
            {
                LL w=L/2;
                ans2-=w*(w+1);
                if (L%2==1) ans2-=(L+1)/2;

                z-=L;
                if (L%2==0)
                {
                    z--;
                    ans2-=L/2;

                    LL w=z/2;
                    ans2-=w*((L-1)/2*2+1-w);
                    if (z%2==1) ans2-=(L-1)/2+1-w;
                }
            }
            L--;
        }
        //cout<<ans2<<" ";
        swap(B,C);
        if (B+L>=A+C)
        {
            L++;
            LL z=B+L-A-C;
            //cout<<"()"<<L<<"  "<<z;
            if (z<=L)
            {
                LL w=z/2;
                ans2-=w*(w+1);
                if (z%2==1) ans2-=(z+1)/2;
                //cout<<"* ";
            }
            else
            {
                LL w=L/2;
                ans2-=w*(w+1);
                if (L%2==1) ans2-=(L+1)/2;

                z-=L;
                if (L%2==0)
                {
                    z--;
                    ans2-=L/2;
                   // cout<<"** ";
                    LL w=z/2;
                    ans2-=w*((L-1)/2*2+1-w);
                    if (z%2==1) ans2-=(L-1)/2+1-w;
                }
            }
            L--;
        }
        //cout<<ans2<<" "<<endl;
        ans=ans+max(0LL,ans2);
    }
    cout<<ans;
    return 0;
}

#include<stdio.h>
int min(int x,int y)
{
    return x<y?x:y;
}
int main()
{
    int a,b,c,l;
    scanf("%d%d%d%d",&a,&b,&c,&l);
    if(a>b)
    {
        int tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c)
    {
        int tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b)
    {
        int tmp=a;
        a=b;
        b=tmp;
    }
    if(a+b+l<=c)printf("0\n");
    else
    {
        long long ans=0;
        for(long long i=c;;i++)
        {
            if(i+1-(a+b)+(i-c)>l)break;
            long long tot=(i-1)*(i-1);
            if(2*(i-1)-(a+b)+(i-c)>l)
            {
                int duo=2*(i-1)-(a+b)+(i-c)-l;
                if(duo<=i-1-b)tot=tot-(long long)(duo+1)*(duo+2)/2;
                else
                {
                    int st=duo-(i-1-b)+1,ed=duo+1;
                    tot=tot-(long long)(st+ed)*(ed-st+1)/2;
                }
            }
            tot=tot-(i-1)*(a-1)-(i-1)*(b-1)+(a-1)*(b-1);
            if(a+b<=i)
            {
                int need=i-(a+b);
                tot=tot-(long long)(need+1)*(need+2)/2;
            }
            ans=ans+tot;
        }
        for(long long i=c+1;;i++)
        {
            if(i+1-(a+c)+(i-b)>l)break;
            long long tot=(i-1)*(i-1);
            if(2*(i-1)-(a+c)+(i-b)>l)
            {
                int duo=2*(i-1)-(a+c)+(i-b)-l;
                if(duo<=i-1-c)tot=tot-(long long)(duo+1)*(duo+2)/2;
                else
                {
                    int st=duo-(i-1-c)+1,ed=duo+1;
                    tot=tot-(long long)(st+ed)*(ed-st+1)/2;
                }
            }
            tot=tot-(i-1)*(a-1)-(i-1)*(c-1)+(a-1)*(c-1);
            if(a+c<=i)
            {
                int need=i-(a+c);
                tot=tot-(long long)(need+1)*(need+2)/2;
            }
            ans=ans+tot;
        }
        for(long long i=c;;i++)
        {
            if(i+1-(c+b)+(i-a)>l)break;
            long long tot=(i-1)*(i-1);
            if(2*(i-1)-(c+b)+(i-a)>l)
            {
                int duo=2*(i-1)-(c+b)+(i-a)-l;
                if(duo<=i-1-c)tot=tot-(long long)(duo+1)*(duo+2)/2;
                else
                {
                    int st=duo-(i-1-c)+1,ed=duo+1;
                    tot=tot-(long long)(st+ed)*(ed-st+1)/2;
                }
            }
            tot=tot-(i-1)*(c-1)-(i-1)*(b-1)+(c-1)*(b-1);
            if(c+b<=i)
            {
                int need=i-(c+b);
                tot=tot-(long long)(need+1)*(need+2)/2;
            }
            ans=ans+tot;
        }
        for(long long i=c;;i++)
        {
            if(i-c+i-b>l)break;
            int maxm=min(i-1,a+l-(i-c+i-b));
            if(maxm>=a)ans=ans+maxm-a+1;
        }
        for(long long i=c;;i++)
        {
            if(i-c+i-a>l)break;
            int maxm=min(i-1,b+l-(i-c+i-a));
            if(maxm>=b)ans=ans+maxm-b+1;
        }
        for(long long i=c+1;;i++)
        {
            if(i-b+i-a>l)break;
            int maxm=min(i-1,a+l-(i-c+i-b));
            if(maxm>=c)ans=ans+maxm-c+1;
        }
        for(long long i=c;;i++)
        {
            if(i-c+i-b+i-a>l)break;
            ans++;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 2000000
#define INF 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    a b c
    increase each stick, sum <= l
    can not increase any stick

    INPUT
        a b c l (a,b,c: 1->3e5, l: 0->3e5)
    OUPUT
        number of way increase

 Idea
    a+x + b+y <= c+z
        x, y => find how many z

    f(a,b,c,l)
        g(a,b,c+i, l-i)

    x, y, z
    x+y+z <= l
    a <= x < l/2
    b <= y < l/2
    c <= z < l/2

    f(x, y) = (|x-y| + 1, c)  (|x+y| - 1, l-x-y)
    f(x, y:1)

    x+y = u
    x: a->u-b
    |x-y| => |u - 2a| => |u-2b|

    x+y = u

    triangle
        range(max(c, |x-y| + 1), min(x+y-1, l-x-y))

    each x-y = d

    ways(u) ways(u) x,y,z x+y = u and satisfy conditions
        x: a => y = u-a  triangle(a,u-a)
        y:b => x = u-b   triangle(u-b,b)

        u-2 > z => ways(u-2, l-2)
        x-1, y-1 z

        z = u-1 <= l-u => range(a, u-b)
        z = u-2 <= l-u => range(max(a,2), min(u-b, u-2))

    ways(a+b) = triangle(a,b)
    ways(a+b+1) = triangle(a+1, b) + triangle(a, b+1);

    ways(u, l) = ways(u-2, l-2) + C;
    ans(l) = ways(a+b) + ways(a+b+1) + ans(l-2) + sum(C)

    g(l) = sum(ways(i, l)) 1:a+b->l

 Seond Idea
 ways(u) x+y+z <= l
    x = a || y = b
        x = a
            u[i] = u[i-1] + pair(i-a, a+1, b, c), i:1->l
        y = b
            v[i] = v[i-1] + pair(i-b, b+1, a, c), i:1->l
        x = a && y = b
            triangle(a, b)

    z = x+y-1
        2x+ 2y <= l + 1
        t[i]
            t[i-1] l even
            t[i-1] + pair((i+1)/2, INF, a+1, b+1)
            i: 1->l

    z = x+y-2
        2x + 2y <= l + 2    y[l]
        w[l]
            w[l-1] l even
            w[l-1] + pair((l+2)/2, INF, a+1, b+1)
            i: 1->l

    pair (sum, dif, a, b)
        range( max(ceil((sum-dif)/2.0), a), min((sum+dif)/2, sum-b))

 ways(i) = ways(i-2) + u[i] + v[i] - range(max(abs(a-b) + 1, c), min(a+b-1, i-a-b)) + t[i] + w[i]

    Complexity(O(N))

 Test
 1 1 1 5

 i:2
    u[3] = getPair(2,2,1,1) = 1
    v[3] = getPair(2,1,1,1) = 1
    t[3] = getPair(2, INF, 1, 1) = 1
    x, y , z = 1
    w[3] = getPair(2, INF, 2, 2) = 0

    ways[3] = 1 + 1 - 1 + 0 + 0

    u[4] = u[3] + getPair(3,0,1,1) = 1
    v[4] = 1

    t[4] = getPair(2, INF, 1 , 1)

 */

int range(int x, int y){
    return max(y-x+1, 0);
}

int getPair(int sum, int dif, int a, int b){
    return range(max((int)ceil((sum-dif)/2.0), a), min((sum+dif)/2, sum-b));
}

ll u[N]{0}, v[N]{0}, w[N]{0}, t[N]{0}, ways[N]{0};

int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int a,b,c,l;
    cin >> a >> b >> c >> l;
    l = l + a + b + c;
    go(i,2,l){
        u[i] = u[i-1] + getPair(i-a, a-1, b, c);
        v[i] = v[i-1] + getPair(i-b, b-1, a, c);
        t[i] = t[i-1];
        if(i%2 == 1) t[i] += getPair((i+1)/2, INF,  a+1, b+1);
        w[i] = w[i-1];
        if(i%2 == 0) w[i] += getPair((i+2)/2, INF, a+1, b+1);
        ways[i] = ways[i-2] + u[i] + v[i] - range(max(abs(a-b) + 1, c), min(a+b-1, i-a-b)) + t[i] + w[i];
        cout << ways[i] << endl;
    }
    cout << ways[l] << endl;
    return 0;
}

#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct greater1
{
      template<class T>
      bool operator()(T const &a, T const &b) const { return a > b; }
};

struct smaller1
{
      template<class T>
      bool operator()(T const &a, T const &b) const { return a < b; }
};

void sochet(int n, int k, int pred, vector<int> mas){
      if (k == 0){
            for (int i = 0; i < mas.size(); i++)
                  cout << mas[i] << " ";
            cout << endl;
      }
      else{
            for (int i = pred; i <= n; i++){//i = pred + 1 sochetania bez povtorenii
                  mas[k-1] = i;
                  sochet(n, k - 1, i, mas);
            }
      }
}
void perest(int n, int k, vector<int> mas, vector<int> isp){
      if (isp.size() == 0){
            for (int i = 0; i < mas.size(); i++)
                  cout << mas[i] << " ";
            cout << endl;
      }
      else{
            for (int i = 0; i < isp.size(); i++){
                  mas[k] = isp[i];
                  vector <int> kaka = isp;
                  kaka.erase(kaka.begin() + i);
                  perest(n, k+1, mas, kaka);
            }
      }
}

bool pairCompare1(const std::pair<int, int>& firstElem, const std::pair<int, int>& secondElem) {
      return firstElem.first < secondElem.first;

}

bool pairCompare2(const std::pair<int, int>& firstElem, const std::pair<int, int>& secondElem) {
      return firstElem.first > secondElem.first;

}
long long cnk(int n, int k){
      if (k > n)
            return 0;
      long long res = 1;
      for (int i = 0; i < k; i++)
            res = res * (n - i) / (i + 1);
      return res;
}

int main() {
      int a, b, c, l;
      int aa = 0, bb = 0, cc = 0;
      cin >> a >> b >> c >> l;
      long long  all = cnk(l + 3, 3);
      for (int i = 0; i <= l; i++){
            aa += cnk(min(l - i, ((a + i) - b - c)) + 2, 2);
      }
      for (int i = 0; i <= l; i++){
            bb += cnk(min(l-i,((b + i) - a - c)) + 2, 2);
      }
      for (int i = 0; i <= l; i++){
            cc += cnk(min(l - i, ((c + i) - a - b)) + 2, 2);
      }
      cout << all - aa - bb - cc;
      return 0;
}

#include<stdio.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
using namespace std;
typedef pair<int,int> p;
typedef pair<p,int> pii;
#define MOD 1000000007
int main()
{
    int a,b,c,l;

    scanf("%d%d%d%d",&a,&b,&c,&l);
    int i,j,k;
    int itill,jtill,ktill,kstart;
    itill = (b+c+l-a)/2;
    jtill = (a+c+l-b)/2;
    int count = 0;
    int ta,tb;
    for(i = 0 ; i <= itill ; i++)
    {
        for(j = 0 ; j <= jtill ; j++)
        {
            ta = a+i;
            tb = b+j;
            kstart = abs(a+i - b-j)-c;
            kstart++;
            ktill = ta+tb-c;
            ktill--;
            kstart = max(kstart , 0);
            ktill = min(ktill , l - i - j);

            if(kstart > ktill)
                count += 0;
            else
            {
//              printf("Adding %d\n",ktill - kstart+1);
                count += ktill - kstart+1;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}

#include <iostream>

using namespace std;

long long max_one_part(int a, int b, int c, int l) {
    long long ret = 0;

    for (int l_a = 0; l_a <= l; l_a ++) {
        if (a + l_a < b + c)
            continue;

        int x = min(l-l_a, a - b - c + l_a);
        ret += ((x + 1) * (x + 2) / 2);
    }
    return ret;
}

long long solve(int a, int b, int c, int l) {

    long long total = 0;

    for (int i = 0; i <= l; i++) {
        total += (i + 1) * (i + 2) / 2;
    }

    long long sum = 0;
    sum += max_one_part(a, b, c, l);
    sum += max_one_part(b, a, c, l);
    sum += max_one_part(c, a, b, l);

    return total -  sum;
}

int main() {

    int a, b, c, l;

    cin >> a >> b >> c >> l;

    cout << solve(a, b, c, l) << endl;

    return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

long long a,b,c,l,ans;

int check(int a,int b,int c)
{
	return a<b+c&&b<a+c&&c<a+b;
}

int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&l);
	if(check(a,b,c)) ans=1;
	for(long long i=1;i<=l;i++)
	{
		long long ttt=(a+b+c+i+1)>>1;
		long long k=i+2;
		ans+=k*(k-1)/2;
		if(a+i>=ttt) ans-=max((i-ttt+a+1)*(i-ttt+a+2)/2,0ll);
		if(b+i>=ttt) ans-=max((i-ttt+b+1)*(i-ttt+b+2)/2,0ll);
		if(c+i>=ttt) ans-=max((i-ttt+c+1)*(i-ttt+c+2)/2,0ll);
	}
	printf("%lld\n",ans>0?ans:0ll);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll A,B,C,L;
ll ret;
ll dp[303030];

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>A>>B>>C>>L;

	dp[0]=1;
	for(i=1;i<=300000;i++) dp[i]=dp[i-1]+i/2+1;

	for(i=0;i<=L;i++) {
		ll a=A+i;
		ll left = L-i;
		ret += (left+1)*(left+2)/2;

		FOR(j,2) {
			ll b=B,c=C,l=left;
			if(a+b>=c) {
				l-=a+b-c;
				if(l>=0) ret-=dp[l];
			}
			else {
				ll di=c-(a+b);
				if(di>=l) {
					ll s=l+1,e=l+1-(di-1);
					ret -= (s+e)*(e-s+1)/2;
					ret-=dp[l-di];
				}
				else {
					ret -= (l+1)*(l+2)/2;
				}
			}

			swap(B,C);
		}

		// B+b+C+c<=a
		ll x=min(left,a-B-C);
		if(x>=0) ret -= (x+1)*(x+2)/2;
	}
	cout<<ret<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MAXN ll(1e5)
#define INF  ll(1e17)
typedef long long ll;

ll sum[111111], ZOM[1111111];

inline ll get(ll a, ll b, ll c, ll l){
    ll x, ans = 0, F = b+c-a;
    if (a < c+b)
        a+=F, l-=F;

    x = a-b-c;

    if (a == b+c)
        ans += 2*ZOM[(l+2)/2];
    else{
        ans += 2*ZOM[(l-x+2)/2]-ZOM[x+1];
    }
    if(l%2==0) ans-=sum[(l-x)/2+1];
    return ans;
}

ll a, b, c, l;
main () {
    cin >> a >> b >> c >> l;
    if (a+b+c+l <= max(a, max(b, c))*2){
        cout << 0;
        return 0;
    }

    for (ll i = 1; i <= l+1; ++i){
        sum[i] += sum[i-1]+i;
        ZOM[i] += sum[i]+ZOM[i-1];
    }

    ll ans = get(a, b, c, l)+get(b, a, c, l)+get(c, b, a, l);

    cout << ZOM[l+1]-ans;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
	long long e[3], l, ans = 0;
	cin >> e[0] >> e[1] >> e[2] >> l;

	//case 1 only 1 longest
	for(int i = 0; i < 3; ++i)
	{
		for(int j = 0; j < l; ++j)
		{
			long long newE[3], sav[3];
			memcpy(newE, e, sizeof e);
			newE[i] += j;
			memcpy(sav, newE, sizeof sav);
			sort(sav, sav + 3);
			if(sav[2] == newE[i] && sav[1] != sav[2]) //i is the longest
			{
				vector<long long> rem;
				long long sum = 0;
				for(int k = 0; k < 3; ++k)
				{
					if(k == i) continue;
					rem.push_back(newE[i] - newE[k] - 1);
					sum += newE[k];
				}
				long long least = newE[i] - sum + 1;
				long long remL = l - j;
				if(remL > rem[0] + rem[1])
					remL = rem[0] + rem[1];
				if(remL < least) continue;
				if(least <= min(rem[0], rem[1]))
				{
					ans += (least + min(remL, min(rem[0], rem[1]))) * (min(remL, min(rem[0], rem[1])) - least + 1) / 2;
					least = min(rem[0], rem[1]) + 1;
				}
				if(remL < least) continue;
				if(least <= max(rem[0], rem[1]))
				{
					ans += (min(rem[0], rem[1]) + 1) * (min(remL, max(rem[0], rem[1])) - least + 1);
					least = max(rem[0], rem[1]) + 1;
				}
				if(remL < least) continue;
				ans += (min(rem[0], rem[1]) + min(rem[0], rem[1]) - (remL - max(rem[0], rem[1])) + 1) * (remL - max(rem[0], rem[1])) / 2;
			}
		}
	}
	//case 2, 2 longest

	for(int i = 0; i < 3; ++i)
		for(int j = i + 1; j < 3; ++j)
		{
			for(int L = max(e[i], e[j]); L <= 6 * 100000; ++L)
			{
				long long need = L - e[i] + L - e[j];
				if(need > l) break;
				long long newE[3];
				memcpy(newE, e, sizeof e);
				newE[i] = L, newE[j] = L;
				int remL = l - need, other;
				bool isLarge = true;
				for(int k = 0; k < 3; ++k)
					if(k != i && k != j)
					{
						if(newE[k] >= L)
							isLarge = false;
						else
							other = newE[k];
					}
				if(!isLarge) continue;
				ans += min(remL + 1, L - other);
			}
		}

	//case 3, 3 longest
	for(int L = max(e[0], max(e[1], e[2])); L <= 6 * 100000; ++L)
	{
		long long need = L - e[0] + L - e[1] + L - e[2];
		if(need > l) break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <cstdlib>
using namespace std;
int solve(int a,int b,int c,int l)
{
	unsigned long long int ans;
	if(a<b+c)return 0;
	if(a-b-c<l)
	{
		ans=a-b-c;
	}
	else
	{
		ans=l;
	}
	return (ans+1)*(ans+2)/2;
}
int main()
{
	unsigned long long int sum,a[3],l;
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
	}
	cin>>l;
	sum=((l+3)*(l+2)*(l+1))/6;
	for(int i=0;i<=l;i++)
	{
		sum-=solve(a[1]+i,a[2],a[3],l-i);
		sum-=solve(a[2]+i,a[3],a[1],l-i);
		sum-=solve(a[3]+i,a[1],a[2],l-i);
	}
	cout<<sum<<endl;
}

#include<bits/stdc++.h>

#define connecting using
#define to namespace
#define wifi std
#define pb push_back
#define pb2 pop_back
#define pf push_front
#define pf2 pop_front
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pr printf
#define sc scanf
#define rep(i,j,k) for(int i=j;i<(int)k;i++)
#define repd(i,j,k) for(int i=j;i>=(int)k;i--)
#define reps(i,j,k) for(int i = j;i<=(int)k;i++)
#define line printf("\n");
#define pq priority_queue
#define haha printf("hahaha\n");

const int INF = 1E9 +7;
const long long INFLL = 1E17;
const double phi = 2*acos(0); // 3.1415926535
const double EPS = 1E-9;

typedef long long ll;
connecting to wifi;

void beda(int a[],int n){

}

int main(){
	int a[3],n;

	scanf("%d%d%d%d",&a[0],&a[1],&a[2],&n);

	int tmp[3];
	ll ret = 0;

	rep(k,0,3){
		rep(i,0,3)tmp[i] = a[i];
		swap(tmp[0],tmp[k]);

		rep(k,0,n+1){
			ll x = min(tmp[0]-tmp[1]-tmp[2]+k,n-k);
			if(x>=0)ret+= (x+1)*(x+2)/2;
		}
	}

	ret = (n+1)*(n+2)*(n+3)/6 - ret;
	cout<<ret<<endl;
	return 0;
}

#pragma comment(linker,"/stack:67108864")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <climits>
#include <cfloat>
#include <functional>
#include <ctime>
#include <numeric>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <utility>
#include <bitset>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <typeinfo>
#include <cassert>
#include <ctime>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forn1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = int(n); i > 0; --i)
#define foran(i, a, n) for(int i = int(a); i <= int(n); ++i)

#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define all(v) (v).begin(),(v).end()

typedef long double ld;
typedef long long ll;

const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
const ll INF = 1000 * 1000 * 1000 + 9;
const int NMAX = 1000*1000 + 3;

int a, b, c, l;

inline bool read()
{
    if (!(cin >>a >>b >>c >>l))
        return false;
    return true;
}

ll calc(int a, int b, int len)
{
    ll ans = 0;
    if (a > b) swap(a, b);
    if (len <= a && len <= b)
        ans = ((len + 2) * (len + 1)) / 2;
    else
    {
        ans = (a + 1) * (min(len, b) + 1);
        if (len <= b) ans = ((len - a + 1 + len + 1) * (a + 1)) / 2;
        if (len <= a + b)
        {
            ans = (a + b - len) * (len - a + 1 + b)/2;
            ans += b * (len - b);
        }
    }
    return ans;
}

ll calc(int a, int b, int c, int l)
{
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        if (b + c + l - i <= newa) continue;
        int addmin = max(0, newa - b - c + 1);
        int addmax = l - i;
        int mlb = newa - b - 1;
        int mlc = newa - c - 1;
        if (mlb < 0 || mlc < 0) continue;
        if (mlb + mlc < addmin) continue;
        ans += calc(mlb, mlc, addmax) - calc(mlb, mlc, addmin - 1);
        //cerr <<mlb <<' ' <<mlc <<' ' <<addmax <<endl;//calc(mlb, mlc, addmax) <<endl;
    }
    return ans;

}

ll calc1(int a, int b, int c, int l)
{
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        int newb = newa;

        if (newb < b) continue;
        int addmin = i + (newb - b) ;
        if (addmin > l) continue;
        if (newa <= c) continue;
        ans += min(l - addmin + 1, newa - c);
    }
    return ans;
}

ll calc2(int a, int b, int c, int l)
{
    ll ans = 0;
    forn(i, l + 1)
    {
        int newa = a + i;
        int newb = newa;
        int newc = newa;

        if (newb < b) continue;
        if (newc < c) continue;
        int addmin = i + (newb - b) + (newc - c) ;
        if (addmin > l) continue;
        ans ++;
    }
    return ans;
}

inline void solve()
{
    ll ans = 0;
    ans += calc(a, b, c, l);
    ans += calc(b, a, c, l);
    ans += calc(c, a, b, l);
    ans += calc1(a, b, c, l);
    ans += calc1(a, c, b, l);
    ans += calc1(b, c, a, l);
    ans += calc2(a, b, c, l);
    cout <<ans <<endl;
}

int main()
{
    ifstream ifile("input.txt");
    if (ifile) {
        freopen("input.txt", "rt", stdin);
    }
#ifdef ONLINE_JUDGE
    if (ifile) {
        freopen("output.txt","wt",stdout);
    }
#endif
    while(read())
        solve();
    return 0;
}

#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

long long  a,b,c,l,ans,s,maxn;

long long int minn(long long int xx,long long int yy){
    if(xx<yy){
        return xx;
    }
    return yy;
}

long long g(long long x,long long y,long long z)
{
	long long temp,p=0;
	for(long long i = x;i<=x+l;i++)
	{
		if(y+z<=i)
		{
			temp = minn(i,maxn-i)-y-z;
			p += (temp+1)*(temp+2)/2;
		}

	}
	return p;
}

int main()
{

	cin>>a>>b>>c>>l;
	maxn = a+b+c+l;
	s = 0;
	for(int i = 0;i<=l;i++)
	{
		s += (i+1)*(i+2)/2;
	}
	s -=g(a,b,c);
	s -=g(b,a,c);
	s -=g(c,a,b);
	cout<<s<<endl;

}

#include <iostream>
#include <ctime>
#include <fstream>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <utility>
#include <cctype>

using namespace std;

#define FORALL(i,a,b) for(int i=(a);i<=(b);++i)
#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORB(i,a,b) for(int i=(a);i>=(b);--i)

typedef long long ll;
typedef long double ld;
typedef complex<int> vec;

typedef pair<int,int> pii;
typedef map<int,int> mii;

#define pb push_back
#define mp make_pair

// all three the same
ll solve_three(int A, int B, int C, int L) {
  ll ans = 0;
  for(int x=0;x<=L;++x) {
    int V = A+x;

    int y = V-B;
    int z = V-C;

    if (y<0 || z<0) continue;
    if (x+y+z > L) continue;
    ++ans;
  }

  return ans;
}

// two max, one min
ll solve_two(int A, int B, int C, int L) {
  int Q[3] = {A,B,C};

  ll ans = 0;
  FOR(i,3) {  // pick the minimum guy
    A = Q[i];
    B = Q[(i+1)%3]; // B and C will tie for max
    C = Q[(i+2)%3];
    for(int z = 0; z <= L; ++z) {
      int V = C+z;
      if (V <= A) continue;
      if (V < B) continue;

      int y = V-B;
      if (y+z > L) continue;

      int lim_x = min(L-y-z,V-A-1);

      assert(y >= 0);
      assert(lim_x >= 0);
      assert(B+y == C+z);
      assert(A+lim_x < V);
      ans += lim_x+1; //(0..lim_x)
    }
  }

  return ans;
}

#define clamp(p,a,b) max(min((p),(b)),(a))

#define f(y) \
  (sx = max(V+1-(B+(y))-A, 0),\
  tx = min(V-1-A, L-z-y),\
  max(tx-sx+1,0))

ll sum(ll a, ll b) {
  assert(a<=b);
  return 1ll*b*(b+1)/2 - 1ll*a*(a-1)/2;
}

// exactly one maximum
ll solve_one(int A, int B, int C, int L) {
  int Q[3] = {A,B,C};

  int sx,tx;

  ll ans = 0;
  FOR(i,3) { // pick the maximum
    A = Q[i];
    B = Q[(i+1)%3];
    C = Q[(i+2)%3]; // C will be the maximum

    for(int z=0;z<=L;++z){
      int V = C+z;
      int x_lim = min(V-A-1,L-z);
      int y_lim = min(V-B-1,L-z);

      if (V <= B || V <= A) continue;
      if (A+B+L-z <= V) continue;
      if (A+x_lim + B+y_lim <= V) continue;

      const int K = 6;

      int S[K] = {y_lim, 0, V+1-A-B, V+1-A-B-x_lim, L-z, L-z-x_lim};
      sort(S,S+K);
      //FOR(j,K) cout << S[j] << " "; cout << endl;
      FOR(j,K-1) {
        if (S[j] < 0) continue;
        if (S[j+1] > y_lim+1) continue;

        int y0 = S[j];
        int y1 = S[j+1]-1;
        int f0 = f(y0);
        int f1 = f(y1);
        if (y0 > y1) continue;
        assert(f0 == f1 || abs(f0-f1) == abs(y0-y1));
        ans += 1ll*sum(min(f0,f1), max(f0,f1));
      }
      //for (int x=0;x<=x_lim;++x) {
      //  for (int y=0; y <= min(L-z-x, V-B-1); ++y)
      //  if (A+x+B+y > V) ++ans;
      //}

      //if (A+x_lim + B+y_lim <=V) continue;
      //int choices = min(y_lim - max(0, V+1-x_lim) + 1, x_lim - max(0, V+1-y_lim) + 1);
      //choices = max(choices,0);
//      int choices = min(min(x_lim, y_lim), )
 //     int choices = y_lim - max(0,V+1-x_lim) + 1;
      //ans += choices;
    }
  }

  return ans;
}

int main() {
  int A,B,C,L;
  scanf("%d%d%d%d",&A,&B,&C,&L);
  ll ans = solve_one(A,B,C,L) + solve_two(A,B,C,L) + solve_three(A,B,C,L);
  /*ll ans = 0;
  for(int x=0;L;x++,L--) {
    ll here = solve(A+x,B,C,L);
    cout << x << " " << here << endl;
    ans += here;
  }*/

  cout << ans << endl;
}

#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

long long  a,b,c,l,ans,s,maxn;

long long int minn(long long int xx,long long int yy){
    if(xx<yy){
        return xx;
    }
    return yy;
}

long long g(long long x,long long y,long long z)
{
	long long temp,p=0;
	for(long long i = x;i<=x+l;i++)
	{
		if(y+z<=i)
		{
			temp = minn(i,maxn-i)-y-z;
			p += (temp+1)*(temp+2)/2;
		}

	}
	return p;
}

int main()
{

	while(cin>>a>>b>>c>>l)
	{
		maxn = a+b+c+l;
		s = 0;
		for(int i = 0;i<=l;i++)
		{
			s += (i+1)*(i+2)/2;
		}
		s -=g(a,b,c);
		s -=g(b,a,c);
		s -=g(c,a,b);
		cout<<s<<endl;
	}

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ld, ld> dd;
typedef pair<ll, ll> llll;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<llll> vllll;
typedef vector<vi> vvi;
typedef vector<ld> vd;
typedef vector<dd> vdd;
#define INF 1000000000
#define EPS 1e-9
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define contains(x, y) ((x).find(y)!=end(x))
#define mk make_pair
#define pb push_back
#define fst first
#define snd second
#define sz(a) ll((a).size())
#define endl "\n"
#define MODU 1000000007

ll dp[3000][3000];

void run(){

	ll n, m;
	string s;
	cin >> n >> m;

	cin >> s;

	ll depth = 0;
	ll mini = INF;
	for(int i = 0; i < m; i++){
		if(s[i] == '(') depth++;
		else depth--;
		mini = min(depth, mini);
	}

	dp[0][0] = 1;
	for(int i = 1; i<= n-m; i++){
		dp[i][0] = dp[i-1][1];
		for(int j = 1; j <= i; j++){
			dp[i][j] = (dp[i-1][j-1]+dp[i-1][j+1]) % MODU;
		}
	}

	ll sum = 0;
	for(int i = 0; i <= n-m; i++){
		for(int j = 0; j <= i; j++){
			if(-mini <= j && j+depth <= n-m-i) sum = (sum+((dp[i][j]*dp[n-m-i][j+depth])%MODU))%MODU;
		}
	}

	cout << sum << endl;
}

int main() {
	cout << fixed << setprecision(16);

	run();

	return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5+10;
typedef long long ll;
ll a, b, c, l, maxn;

ll sol(ll x, ll y, ll z)
{
	ll tmp = 0;
	for(ll i = x; i <= x+l; i++)
	{
		if((y + z) <= i)
		{
			ll cnt = min(i, maxn - i) - y - z;
			tmp += (cnt + 1) * (cnt + 2) / 2;
		}
	}
	return tmp;
}

int main()
{
	while(~scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &l))
	{
		maxn = a + b + c + l;
		ll ans = 0;
		for(int i = 2; i <= l+2; i++)
		{
			ans += (i * (i - 1)) / 2;
		}
		ans -= sol(a, b, c);
		ans -= sol(b, a, c);
		ans -= sol(c, a, b);
		printf("%I64d\n", ans);
	}
	return 0;
}