#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int v[30005];
int main()
{
    int n;
    fin >> n;
    for(int i = 1 ; i <= n ; ++i)
        fin >> v[i];
    sort(v + 1 ,  v + n + 1);
    int contor = 0;
    for(int i = 1 ; i <= n - 2 ; ++i)
        for(int j = i + 1 ; j <= n - 1 ; ++j)
            for(int k = j + 1 ; k <= n ; ++k)
                if((v[i] <= v[j] + v[k])&&(v[k] <= v[i] + v[j])&&(v[j] <= v[i] + v[k]))
                    ++contor;
                else
                    break;
    fout << contor;
}