#include <fstream>
#include <algorithm>

using namespace std;

#define maxN 5000

ifstream input("Bai2_18.inp");
ofstream output("Bai2_18.out");
int n;
int arr[maxN];
int res = 0;
int main()
{
	input >> n;
	for (int i = 0; i < n; ++i)
	{
		input >> arr[i];
	}
	sort(arr, arr + n);
	for (int i = 0; i < n - 1; ++i)
	{
		int k = i + 2;
		for (int j = i + 1; j < n; ++j)
		{
			while (k < n && arr[i] + arr[j] > arr[k])
			{
				++k;
			}
			if (k > j)
			{
				res += k - j - 1;
			}
		}
	}
	output << res;
	input.close();
	output.close();
	return 0;
}