"use strict";

function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)>>1]<e?a=c:b=c;return d[a]<e?b:a};

function Main(arg) {
    const N = arg.split("\n")[0]-0;
    const L = arg.split("\n")[1].split(" ").map(v=>v-0);
 
    let ans = 0;

    let a, b, c;
    L.sort((a,b)=>a-b);
  
    for (let i=0; i<N - 2; i++){
        a = L[i];
      
        for (let j = i+1; j < N - 1; j++){
            b = L[j];
            let tmp = lower_bound(L, j + 1, N, a + b) - 1;
            ans += (tmp - j);
        }
    }


    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
