#include <bits/stdc++.h>
using namespace std;
int n,st,dr,m,a[2000],dif,sum,p1,p2,ans;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            sum=a[i]+a[j];
            st=j;
            dr=n+1;
            while(dr-st>1)
            {
                m=(st+dr)/2;
                if(a[m]>sum) dr=m;
                else st=m;
            }
            if(st<=n)
            ans+=st-j;
        }
    }
    cout<<ans;
    return 0;
}