#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,r,k;
    for (int i=1;i<=n;i++)
    {
        k=i+1;
        for (int j=i+1;j<=n;j++)
        {
            while (k<=n && v[k]<=v[i]+v[j])
            {
                k++;
            }
            if (k>j)
            {
                contor+=k-j-1;
            }
        }
    }
    out<<contor;
    in.close();
    out.close();
    return 0;
}