#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <algorithm>
// #include <chrono>
using	namespace std;
// Reference: http://www.cplusplus.com/reference/algorithm/nth_element/

ifstream	f("nrtri.in");
ofstream	g("nrtri.out");
long int		n, v[801], nr;
int	main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	
	nr = 0;
	f >> n;
	for (int i = 0; i < n; i++)
		f >> v[i];
	
	sort(v, v + n);
	
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			for (int k = j + 1; k < n && v[i] + v[j] >= v[k]; k++)
				nr++;
	g << nr;
	return	0;
}