#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
using namespace std;
int n,i,j,t,c,x,st,dr,med,poz;
vector<int>v;
int main()
{
    ifstream fin("nrtri.in");
    ofstream fout("nrtri.out");
    fin>>n;
    for (i=0;i<n;i++)
    {
        fin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for (i=0;i<v.size();i++) for (j=i+1;j<v.size();j++)
    {
        poz=-1;
        st=j+1;
        dr=v.size()-1;
        while (dr>=st)
        {
            med=(st+dr)/2;
            if (v[i]+v[j]<v[med]) dr=med-1;
            else
            {
                poz=med;
                st=med+1;
            }
        }
        if (poz!=-1)
        {
            c=c+(poz-j);
        }
    }
    fout<<c;
}