#include <bits/stdc++.h>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int v[801];
int main()
{
    int n,i,triunghiuri=0,j,z;
    in>>n;
    for(i=1; i<=n; i++)
        in>>v[i];
    sort(v+1,v+n+1);
    for(i=1; i<=n-2; i++)
        for(j=i+1; j<=n-1; j++)
            for(z=j+1; z<=n; z++)
                if(v[i]+v[j]>=v[z])
                    triunghiuri++;
                else
                    break;
    out<<triunghiuri;
    return 0;
}