// Numarare_Triunghiuri.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
std::ifstream in("nrtri.in");
std::ofstream out("nrtri.out");
int main() {
	long long array[1000];
	long long n, elem;
	in >> n;
	for (auto i = 1; i <= n; i++) {
		in >> array[i];
	}
	long long counter = 0;
	std::sort(array + 1, array + n + 1);
	
	for (int i = 1; i <= n - 2; i++) {
		int k = i + 2;
		for (int j = i + 1; j <= n - 1; j++) {
			while (array[i] + array[j] >= array[k] && k <= n)
				k++;
			if (k > j)
				counter += k - j - 1;
		}
	}
	out << counter;
	return 0;
}