#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int v[850],nr=0;
void cautare(int n,int j,int i)
{
    int r=0;
    for(int p=15; p>=0; p--)
        if(r+(1<<p)<j and v[r+(1<<p)]+v[j]<v[i])
            r+=(1<<p);
            //cout<<j<<" "<<r<<endl;cout<<endl;
        nr=nr+j-r-1;
}
int main()
{
    ifstream cin("nrtri.in");
    ofstream cout("nrtri.out");
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(int i=2; i<=n; i++)
        for(int j=1; j<i; j++)
            cautare(n,j,i);
    cout<<nr;
    return 0;
}