#include <bits/stdc++.h>

using namespace std;

ifstream in("nrtri.in");
ofstream out("nrtri.out");

const int DimMax=1024;

int n,m,s=0;
int v[DimMax];
int mid,st,dr,sol,i,j;

void BinarySearch()
{
    for(i=1; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            s=v[i]+v[j];
            st=j+1;
            dr=n;
            while(st<=dr)
            {
                mid=(st+dr)/2;
                if(v[mid]>s)
                    dr=mid-1;
                else
                    st=mid+1;
            }
            sol+=dr-j;
        }
    }
}

int main()
{
    in>>n;
    for(i=1; i<=n; i++)
    {
        in>>v[i];
    }
    sort(v+1,v+n+1);
    BinarySearch();
    out<<sol;
    return 0;
}