#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
int v[801];
int main()
{
    int i,n,j,k,cnt=0;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<=n-2;i++)
    {
        for(j=i+1;j<=n-1;j++)
        {
             for (k=j+1; k<=n; k++)
            {
                    int s2=v[i]+v[j];
                    int l3=v[k];
                    if (s2>=l3)
                        cnt++;
                    else
                        break;
            }
        }
    }
    cout<<cnt;
    return 0;
}