#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int N, cont;
int main()
{
    in >> N;
    int v[N];
    for(int i = 0; i < N; ++i)
        in >> 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] && v[j] <= v[i] + v[k] && v[k] <= v[i] + v[j])
                    ++cont;
                else break;
    out << cont;
    return 0;
}