function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4).sort(function(a,b){
  	return a-b;
  });
  //myout(list);
  var output = 0;
  for(var i = 0; i < N - 2; i++){
    for(var j = i+1; j < N-1; j++){
      //k(l~r) < i + j
      //これの境界線はどこ？
      //境界値より左側は全部追加
      var l = j+1;
      var r = N-1;
      var c = l+(Math.ceil((r-l)/2));
      myerr(l + " " + r + " " + c);
      var checked = false;
      while(l != c && r != c){
        checked - true;
         if(list[c] < list[i]+list[j]){
           l = c;
           c = l+(Math.ceil((r-l)/2));
         }else{
           r = c;
           c = l+(Math.floor((r-l)/2));
         }
      }
      if(!checked){
         if(list[l] >= list[i]+list[j]){
            continue;
         }
      }
      myerr("i-j:"+i+"-"+j+",i+j:" + (list[i]+list[j]) +", c:"+c +  ",c:" + list[c]);
      if(c == j+1 && list[c] >= list[i]+list[j]){
         myerr("NG");
         continue;
      }
      if(c == N-1){
         //output++;
      }
      myerr("OK:" + (c-j));
      output += c - j;
      
    }
  }
  myout(output);
}

Main(myin());
