#include <bits/stdc++.h>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,k,a[805];
long long sol;
int main()
{
    fin>>n;
    for (int i=1;i<=n;i++)
        fin>>a[i];
    sort(a+1,a+n+1);
    for (int i=1;i<=n-2;i++)
    {
        k=i+2;
        for (int j=i+1;j<=n-1;j++)
        {
            while(a[i]+a[j]>=a[k] && k<=n)
                k++;
            if (k>j)
                sol+=k-j-1;
        }
    }
    fout<<sol<<'\n';
    return 0;
}