#include <bits/stdc++.h>
using namespace std;

signed main () {
	int n;
	cin >> n;
	vector < int > l(n);
	for (int &x: l)
		cin >> x;
	sort(l.begin(), l.end());
	int64_t ans = 0;
	for (int a = 0; a < n; ++a) {
		for (int b = a + 1; b < n; ++b) {
			int c = lower_bound(l.begin(), l.end(), l[a] + l[b]) - l.begin();
			ans += c - b - 1;
		}
	}
	cout << ans << '\n';
}
