//ALEXANDRU MICLEA
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
using namespace std;
#include <fstream>
ifstream cin("nrtri.in"); ofstream cout("nrtri.out");
int v[805];
int n;
int main() {
	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;
}