#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define NMAX 805
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int v[NMAX];
int n;
int valid(int a,int b,int c)
{
    return (a+b >= c && a+c >= b && b+c >= a );
}
int cauta(int a,int b,int st,int dr)
{
    int sol = -1;
    while(st<=dr)
    {
        int m = (st+dr)/2;
        if(valid(v[a],v[b],v[m]))
        {
            sol = m;
            st = m+1;
        }
        else
        {
            dr=m-1;
        }
    }
    return sol;
}
int main()
{
    fin>>n;
    for(int i = 0;i<n;i++)
        fin>>v[i];
    sort(v,v+n);
    int sum = 0;
    for(int i = 0;i<n;i++)
    {
        for(int j = i+1;j<n;j++)
        {
            int x = cauta(i,j,j+1,n-1);
            if(x != -1)
            {
                //cout<<v[i]<<" "<<v[j]<<" "<<v[x]<<endl;
                sum+= x-j;
            }
        }
    }
    fout<<sum;
    return 0;
}