#include <fstream>
#include <algorithm>
using namespace std;
//ifstream cin("text.in"); ofstream cout("text.out");
ifstream cin("nrtri.in"); ofstream cout("nrtri.out");
int v[805];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];
	sort(v + 1, v + n + 1);
	int ans = 0;
	for (int i = 1; i <= n - 2; ++i)
	{
		int pnt = i + 1;
		for (int j = i + 1; j <= n - 1; ++j)
		{
			while (pnt <= n && v[i] + v[j] >= v[pnt])
				pnt++;
			ans += pnt - j - 1;
		}
	}
	cout << ans;
	return 0;
}