#include<iostream>
#include<fstream>
#include <bits/stdc++.h>
using namespace std;

int main(){
	ifstream fin("nrtri.in");
	ofstream fout("nrtri.out");
    long long int n,i,j,k,betisor,counter = 0;
	fin>>n;
	long long int betisoare[n];
	for(i=0;i<n;i++){
        fin>>betisor;
        betisoare[i] = betisor;
    }
    sort(betisoare,betisoare+n);
	for (i=0;i<n-2;i++)
        for(j=i+1;j<n-1;j++)
            for(k=j+1;k<n;k++)
                if(betisoare[i]+betisoare[j]>=betisoare[k])
                    counter++;
                else
                    break;

	fout<<counter;


}