#include<bits/stdc++.h>
        #define ll  long long
        #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define rep(i,a,b)  for(ll i=a;i<b;i++)
        #define pb push_back
        #define Max(x,y,z) max(x,max(y,z))
        #define f first
        #define s second
        #define sz(x)       (ll)x.size()
        #define pi 3.1415926536
        #define mod 1000000007
        #define MOD 998244353
        #define maxi 100000000000000000
        using namespace std;
       const int N=1e5+5;
       ll n;
       /*vector<ll> adj[205];
       ll lvl[205];
       ll col[205];
       bool vis[205];
       bool flag=1;*/
      /* bool dfs(ll x)
       {   vis[x]=1;
           for(auto y:adj[x])
           {
               if(!vis[y])
               {
                   if(col[y]==-1)
                   {
                       col[y]=1-col[x];
                        return flag=(flag && dfs(y));
                   }
               }
               else if(col[y]==col[x])
                    return 0;

           }
           return flag;
       }*/
       /*ll dp[N][25],dp2[N][25];
       ll logcal[N];*/
/*       void update(ll x,ll value,ll pos)
{
    while(pos<=n)
    {
        bit[x][pos]+=value;
        pos+=(pos)&(-pos);
    }
}
ll query(ll x,ll pos)
{  ll ans=0;
    while(pos>0)
    {
        ans+=bit[x][pos];
        pos-=(pos)&(-pos);
    }
    return ans;
}*/
    /*
    bool vis[N];
    ll cnt=0;
    void dfs(ll x)
    {
        vis[x]=1;
        cnt++;
        for(auto y:adj[x])
            if(!vis[y]) dfs(y);
    }*/
      /* ll dfs(ll x,bool vis[],bool rec[])
    {   //cout<<x<<" ";
        vis[x]=1;
        rec[x]=1;
        for(auto y:adj[x])
            if(!vis[y] && dfs(y,vis,rec)) return true;
            else if(rec[y]) return true;
        rec[x]=false;
        return false;
    }*/
        /*bool isprime(ll x)
        {
            for(ll i=2;(i*i)<=x;i++)
            {
                if(x%i==0) return 0;
            }
            return 1;
        }*/
        /*vector<ll> _lps(string &t)
        {   ll n=t.size();
            vector<ll> lps(n+1,0);
            ll i=1,len=0;
            while(i<n)
            {
                if(t[i]==t[len])
                {
                    len++;
                    lps[i]=len;
                    i++;
                }
                else
                {
                    if(len!=0)
                        len=lps[len-1];
                    else
                        lps[i++]=0;
                }
            }
            return lps;
        }
        ll KMP(string &s,string &t)
        {
            ll n=s.size();
            ll m=t.size();
            vector<ll> lps=_lps(t);
            ll i=max(0LL,n-m),j=0;
            while(i<n)
            {
                if(s[i]==t[j])
                {
                    i++;
                    j++;
                }
                else
                    if(j!=0) j=lps[j-1];
                    else i++;
            }
            return j;

        }*/
        void solve()
        {
                    ll m,y,z,h,b,c,d,e,k1,k2,p,x,k,a;
                    cin>>n;
                    vector<ll> ar(n);
                    rep(i,0,n)
                    {
                        cin>>ar[i];
                    }
                    if(n<3) {cout<<"0";return;}
                    sort(ar.begin(),ar.end());
                    ll ans=0;
                    rep(i,0,n-2)
                    {    x=ar[i];
                        rep(j,i+1,n-1)
                        {
                            y=ar[j];
                            z=lower_bound(ar.begin(),ar.end(),x+y)-ar.begin();
                            if((z-1)>j) {ans+=(z-j-1);}
                        }
                    }
                    cout<<ans;
                    /*cout<<"\n";
                    rep(i,0,n-2)
                    {
                        rep(j,i+1,n-1)
                        {
                            rep(k,j+1,n)
                            if(ar[i]+ar[j]>ar[k] && ar[i]+ar[k]>ar[j] && ar[j]+ar[j]>ar[i] ) {cout<<ar[i]<<ar[j]<<ar[k]<<"\n";ans++;}
                        }
                    }
                    cout<<ans;*/




}

                int main()
                {
                    speed_up
                    ll t=1;
                    //call();
                    //cin>>t;
                    while(t--)
                        solve();
                }


Measured memory_bytes: 256