/*
    Sortam elementele, iar apoi luam fiecare pereche de laturi si cautam binar numarul de triunghiuri
in zona ramasa
*/
#include <bits/stdc++.h>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n, st, dr, mij, v[1001], t, u;
int main()
{
    f>>n;
    for(int i=1; i<=n; i++)
        f>>v[i];
    sort(v+1, v+n+1);
    for(int i=1; i<n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            t=v[i]+v[j];
            st=j+1;
            dr=n;
            while(st <= dr)
            {
                mij=(st+dr)/2;
                if(t<v[mij])
                    dr=mij-1;
                else
                    st=mij+1;
            }
            u=u+dr-j;
        }
    }
    g << u;
    return 0;
}