n = int(input())
nums = [int(i) for i in input().split(' ')]
nums.sort()
x=0
for i in range(n-2):
for j in range(i+1,n-1):
k=j+1
while k<n:
if nums[i]+nums[j]>nums[k]:
x+=1
else:
break
k = k + 1
print(x)
#技术有限,只能爆破了