#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int main()
{
    int n, v[801], nr = 0;
    f>>n;
    for (int i=0;i<n;i++)
        f>>v[i];
    sort(v, v+n);
    for(int i = 0; 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])
                    nr++;
                else break;
    g<<nr;
    return 0;
}