#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,i,j,st,dr,mid,v[1010],sol,rasp;
int main(){
    fin>>n;
    for(i=1;i<=n;i++)
        fin>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<n;i++){
        for(j=i+1;j<=n;j++){
            sol=v[i]+v[j];
            st=j+1;
            dr=n;
            while(st<=dr){
                mid=(st+dr)/2;
                if(sol<v[mid])
                    dr=mid-1;
                else
                    st=mid+1;
            }
            rasp+=dr-j;
        }
    }
    fout<<rasp;
    return 0;
}