n = int(input())
a = [int(c) for c in input().split()]
a = sorted(a)
ret = n*(n-1)*(n-2)//6
for i in range(n):
	for j in range(i+1, n):
		low, high = 0, n-1
		pivot = -1
		while (low <= high):
			mid = low + (high - low)//2
			if (a[mid] >= a[i] + a[j]): 
				pivot = mid
				high = mid-1
			else: low = mid+1
		if (pivot != -1): ret -= n-pivot
print(ret)  n = int(input()) n int(input()) int input() input int(c) for c in input().split() for c in input().split() c input().split() ().split () input split for c in input().split() int(c) int c a = [int(c) for c in input().split()] a [int(c) for c in input().split()] a = sorted(a) a sorted(a) sorted a ret = n*(n-1)*(n-2)//6 ret n*(n-1)*(n-2)//6 n*(n-1)*(n-2) n*(n-1) n n-1 n 1 n-2 n 2 6 for i in range(n):
	for j in range(i+1, n):
		low, high = 0, n-1
		pivot = -1
		while (low <= high):
			mid = low + (high - low)//2
			if (a[mid] >= a[i] + a[j]): 
				pivot = mid
				high = mid-1
			else: low = mid+1
		if (pivot != -1): ret -= n-pivot i range(n) range n for j in range(i+1, n):
		low, high = 0, n-1
		pivot = -1
		while (low <= high):
			mid = low + (high - low)//2
			if (a[mid] >= a[i] + a[j]): 
				pivot = mid
				high = mid-1
			else: low = mid+1
		if (pivot != -1): ret -= n-pivot j range(i+1, n) range i+1 i 1 n low, high = 0, n-1 low 0 high n-1 n 1 pivot = -1 pivot -1 while (low <= high):
			mid = low + (high - low)//2
			if (a[mid] >= a[i] + a[j]): 
				pivot = mid
				high = mid-1
			else: low = mid+1
		 low <= high low high mid = low + (high - low)//2 mid low + (high - low)//2 low (high - low)//2 high - low high low 2 if (a[mid] >= a[i] + a[j]): 
				pivot = mid
				high = mid-1
			else: low = mid+1
		 a[mid] >= a[i] + a[j] a[mid] a mid a[i] + a[j] a[i] a i a[j] a j pivot = mid pivot mid high = mid-1 high mid-1 mid 1 if (pivot != -1): ret -= n-piv pivot != -1 pivot -1 print(ret) print ret mid = low + (high - low)//2 low + (high - low)//2 mid n = int(input()) int(input()) n pivot = -1 -1 pivot pivot = mid mid pivot high = 0, n-1 n-1 high a = sorted(a) sorted(a) a ret = n*(n-1)*(n-2)//6 n*(n-1)*(n-2)//6 ret high = mid-1 mid-1 high low, high = 0, n-1 0 low a = [int(c) for c in input().split()] [int(c) for c in input().split()] a
n = int(input())
a = [int(c) for c in input().split()]
a = sorted(a)
ret = n*(n-1)*(n-2)//6
for i in range(n):
	for j in range(i+1, n):
		low, high = 0, n-1
		pivot = -1
		while (low <= high):
			mid = low + (high - low)//2
			if (a[mid] >= a[i] + a[j]): 
				pivot = mid
				high = mid-1
			else: low = mid+1
		if (pivot != -1): ret -= n-pivot
print(ret) 
