#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int main()
{
    int contor = 0;
    int n;
    f >> n;
    int s[805];
    for(int  i = 1; i <= n; i++)
        f >> s[i];
    sort(s + 1, s + n + 1);
    for(int i = 1; i <= n; i++)
        for(int j = i+1; j <= n; j++)
            for(int k = j+1; k <= n; k++)
                if((s[i] + s[j] >= s[k]))
                    contor++;
                else break;
    g << contor;
    return 0;
}