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