#include <iostream>
#include <bits/stdc++.h>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int v[805],n,mod;
int main()
{
    f >> n;
    for (int i=1;i<=n;i++) {
        f >> v[i];
    }
    sort (v+1 , v+n+1);
    for (int i=1;i<=n-2;i++) {
        for (int k=i+1;k<=n-1;k++) {
            for (int j=k+1;j<=n;j++) {
                if (v[i]+v[k]>=v[j] && v[i]+v[j]>=v[k] && v[j]+v[k]>=v[i])
                    mod++;
                else
                    break;
            }
        }
    }
    g << mod;
    return 0;
}