#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int v[860],n,nrsol;
void cautareBinara(int a, int b)
{
    int sum,stg,dr,mid;
    sum=v[a]+v[b];
    stg=max(a,b);
    dr=n;
    while (stg<=dr)
    {
        mid=(stg+dr)/2;
        if (v[mid]>sum)
            dr=mid-1;
        if (v[mid]<=sum)
            stg=mid+1;
    }
    mid=(stg+dr)/2;
    if (v[mid]>sum)
        mid--;
    nrsol=mid-max(a,b)+nrsol;
}

int main()
{
    fin>>n;
    for (int i=1; i<=n; i++)
    {
        fin>>v[i];
    }
    sort(v+1,v+n+1);
    for (int i=1; i<=n-2; i++)
    {
        for (int j=i+1; j<=n-1; j++)
        {
            cautareBinara(i,j);
        }
    }
    fout<<nrsol;

    return 0;
}