#include <bits/stdc++.h>
using namespace std;
ifstream in ("nrtri.in");
ofstream out ("nrtri.out");
int v[801],nr;
int main()
{
    int n,i,j,k;
        in>>n;
    for(i=1;i<=n;i++)
        in>>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[k]<=v[i]+v[j])
                    nr++;
                else
                    break;
            }
    out<<nr;
    return 0;
}