
#include <bits/stdc++.h>
using namespace std;
ifstream fi("bai2.inp");
ofstream fo("bai2.out");
long int i,j,k,n,arr[10000];
int findNumberOfTriangles(long int arr[],long int n)
{

	sort(arr,arr+n-1);
	long int coun = 0;


	for ( i = 0; i < n-2; ++i)
	{

		k = i+2;


		for (j = i+1; j < n; ++j)
		{

			while (k < n && arr[i] + arr[j] > arr[k])
			++k;


			if(k>j)
			coun += k - j - 1;
		}
	}

	return coun;
}


int main()
{
	fi>>n;
	for(i=0;i<n;++i)
        fi>>arr[i];

		fo<<findNumberOfTriangles( arr,n ) ;

	return 0;
}
