#include <fstream>
#include <algorithm>
using namespace std;
 int main()
{
int i,v[805],j,k,sum,n,cont;
ifstream fin ("nrtri.in");
ofstream fout ("nrtri.out");
cont=0;
fin>>n; 
for(i=1;i<=n;i++){
    fin>>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++){
            sum=v[i]+v[j];
            if(sum>=v[k])
                cont++;
            
            else
                break;
        }
fout<<cont;
return 0;
}