#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>

using namespace std;

#define maxN 5000

FILE *input = fopen("Bai2_18.inp", "r");
FILE *output = fopen("Bai2_18.out", "w");
int n;
long long arr[maxN];
int res = 0;
int main()
{
	fscanf(input, "%d", &n);
	for (int i = 0; i < n; ++i)
	{
		fscanf(input, "%lld", &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;
			}
		}
	}
	fprintf(output, "%d", res);
	fclose(input);
	fclose(output);
	return 0;
}