#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

const int L=10;
int n;
int v[805];

int caut(int x)
{
    int r=0,pas=1<<L;
    while (pas!=0)
    {
        if (r+pas<=n && v[r+pas]<=x)
        {
            r+=pas;
        }
        pas/=2;
    }
    return r;
}


int main()
{
    ifstream in("nrtri.in");
    ofstream out("nrtri.out");
    in>>n;
    for (int i=1;i<=n;i++)
    {
        in>>v[i];
    }
    sort(v+1,v+n+1);
    int contor=0,ras;
    for (int i=1;i<=n-2;i++)
    {
        for (int j=i+1;j<n;j++)
        {
            ras=caut(v[i]+v[j]);
            if (ras!=0)
            {
                contor+=ras-j;
            }
        }
    }
    out<<contor;
    in.close();
    out.close();
    return 0;
}