#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
#define nmax 805
int v[nmax],n,nr=0,aux,poz;
int BS(int x)
{
    int sol=-1,left=0,right=n;
    while(left<=right)
    {
        int mid=(left+right)/2;
        if(v[mid]==x)
        {
            sol=mid;
            for(int j=mid+1;j<=n;j++)
            {
                if(v[j]==v[mid])
                    sol++;
                else
                    break;
            }
            break;
        }
        if(v[mid]>x)
            right=mid-1;
        if(v[mid]<x)
            left=mid+1;
    }
    if(sol<0)
    {
        sol=left-1;
        if(x<v[1])
            sol=1;
        if(x>v[n])
            sol=n;
    }
    return sol;
}
int main()
{
    fin>>n;
    for(int i=1;i<=n;i++)
        fin>>v[i];
    sort(v+1,v+1+n);
    for(int i=1;i<=n-2;i++)
    {
        for(int j=i+1;j<=n-1;j++)
        {
            aux=v[i]+v[j];
            poz=BS(aux);
            nr+=poz-j;
        }
    }
    fout<<nr;
}