#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
const int NMAX = 800;
int v[NMAX+5];
///pentru aceasta problema folosim inegalitatea triunghiurilor c <= a + b, unde a, b, c sunt laturile triunghiului
int cautare_binara(int st, int dr, int i, int j)
{
    int mid, sol =0;
    while(st<=dr)
    {
        mid = (st + dr )>>1;
        if(v[mid]<=v[i] + v[j])
        {
            sol = mid;
            st = mid + 1;
        }
        else
            dr = mid-1;
    }
    if(sol == 0)
        return 0;
    return sol - j;
}
int main()
{
     int i, j, n, sol =0;
     fin>>n;
     for(i=1;i<=n;i++)
        fin>>v[i];
     sort(v+1, v + n + 1);
     for(i=1;i<=n-2;i++)
     {
        for(j=i+1;j<=n-1;j++)
        {
           sol = sol + cautare_binara(j+1, n, i, j);
        }
     }
     fout<<sol<<"\n";
    return 0;
}