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

int main(){
        int k, cnt=0, n, p;
        scanf("%d", &n);
        int a[n+1];
        int low, high, mid, j;
        for(j=0; j<n; j++){
            scanf("%d", &a[j]);
            //printf("%d \n", a[j]);
        }
        sort(a, a+n);
        //for(j=0; j<n; j++) printf("%d ", a[j]);
        //printf("\n\n");
        for(j=0; j<n-2;j++){
            for(k=j+1; k<n-1; k++){
                int ans=0;
                p=a[j]+a[k]-1;
                low=k+1;
                high=n-1;
                mid=(low+high)/2;
                while(low<=high){
                    if(a[mid]>p){
                        high=mid-1;
                        mid=(high+low)/2;
                    }
                    else{
                        low=mid+1;
                        mid=(high+low)/2;
                    }
                }
                if(a[mid]<=p) ans=mid-k;
                //ans=ans+k-j-1;
                //if(ans==0) break;
                //printf("%d %d %d\n", a[j], a[k], ans);
                cnt=cnt+ans;
            }
        }
        printf("%d", cnt);
}