parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt
  l = readline() |> split |> parseArray

  sort!(l)
  ans=0
  for i in 1:n
    a=l[i]
    for j in i+1:n
      b=l[j]
      m=0
      n-j==0 && continue
      for h in ceil(Int,log2(n-j)):-1:0
        k=min(j+m+2^h,n)
        c=l[k]
        m+=(c<a+b ? 2^h : 0)
      end
      k=min(j+m,n)
      ans+=k-j
    end
  end
  println(ans)
end

main()
