//ALEX ENACHE
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
using namespace std;
//-----------------------------------------------------------------
#include <fstream>
//ifstream cin("input"); ofstream cout("output");
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;
}