//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++) {
		for (int j = i+1; j <= n-1; j++) {
			int st = j;
			int dr = n;
			int ras = 0;
			while (st <= dr) {
				int mij = st + dr;
				mij /= 2;
				if (v[i] + v[j] >= v[mij]) {
					ras = mij;
					st = mij + 1;
				}
				else {
					dr = mij - 1;
				}
			}
			ans += ras - j;
		}
	}
	cout << ans;
	return 0;
}