#include <fstream>
#include <algorithm>
using namespace std;
int i,j,m,n,a,b,s,t[100005],e,l,x,d,x1,rs;
int c;
    ifstream fin("nrtri.in");
    ofstream fout("nrtri.out");
void caut(int x,int y)
{
    if (x>=y) {s=x; return;}
    int mid=(x+y+1)/2;
    if (t[mid]>x1) caut(x,mid-1);
            else  caut(mid,y);
    return;
}
int main()
{
    fin>>n;
    for (i=1;i<=n;i++)
        fin>>t[i];
    sort(t+1,t+n+1);
    for (i=1;i<=n;i++)
         for(j=i+1;j<=n;j++)
    {
        x1=t[i]+t[j];
        caut(1,n);
        rs+=s-j;
    }
    fout<<rs;
    return 0;
}