#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n,v[801];
int cautbin(int x){
   int p = 1, u = n, poz=0;
    while(p <= u)
    {
        int m = (p + u) / 2; //m=p+(u-p)/2;
        if(x>=v[m]){
            poz=m;
            p=m+1;
        }
        else u=m-1;
    }
    return poz;
}
int main()
{
    f>>n;
    for(int i=1;i<=n;i++)
        f>>v[i];
    sort(v+1,v+n+1);
    int nr=0;
    for(int i=1;i<n-1;i++)
        for(int j=i+1;j<n;j++){
            //poz=cea mai mare pozitie in v pentru care v[i]+v[j]>v[poz]
            int poz=cautbin(v[i]+v[j]);
            nr+=(poz-j); ///Cate pozitii avem intre j+1 si poz;
        }
    g<<nr;
    return 0;
}