#include <iostream>
#include<fstream>
#include<cstring>
#define N 805
#include<algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,a[N];
void read()
{
    int i;
    fin>>n;
    for(i=1;i<=n;++i)
        fin>>a[i];
}
void solve()
{
    sort(a+1,a+n+1);
    int i,j,k,ct=0,sum,dif;
    //alegem 2 betisoare, il cautam si pe al 3 lea in mod convenabil
    //suma oricaror 2 mai mare decat al 3 lea
    //dif oricaror 2 mai mica decat a 3a
    for(i=1;i<=n;++i)
        for(j=i+1;j<=n;++j)
            for(k=j+1;k<=n;++k)
    {
        sum=a[i]+a[j];
        if(sum>=a[k])ct++;
        else break;
    }
    fout<<ct;
}

int main()
{
    read();
    solve();
    return 0;
}