#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int nr,i,j,k,n,v[801];
int main() {
    fin>>n;
    for(i=1; i<=n; ++i)
        fin>>v[i];
    sort(v+1,v+n+1);
    for(i=1; i<n; ++i)
        for(j=i+1; j<n; ++j)
            for(k=j+1; k<=n; ++k)
                if(v[i]+v[j]>=v[k])
                    nr++;
                else
                    break;
    fout<<nr<<'\n';
    return 0;
}