#include<iostream>
#include<fstream>
#include<vector>
#include <algorithm>
using namespace std;

int main(){
	ifstream f("nrtri.in");
	ofstream f1("nrtri.out");
	int n;
	f>>n;
	int v[n];
	for (int i=0;i<n;i++)
		f>>v[i];
	sort (v,v+n);
	int nr=0;
	for (int i=0;i<n-2;i++)
		for (int j=i+1;j<n-1;j++)
			for (int k=j+1;k<n && v[k]<=v[i]+v[j];k++)
				nr++;
					
	f1<<nr;	
		
			
	
	
}