import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()
cnt = 0


for i in range(n-2):
  for j in range(i+1, n-1):
    sum = l[i] + l[j]
    index = bisect.bisect_left(l, sum)
    cnt += index - j - 1

print(cnt) import bisect bisect n = int(input()) n int(input()) int input() input l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split l.sort() l.sort l sort cnt = 0 cnt 0 for i in range(n-2):
  for j in range(i+1, n-1):
    sum = l[i] + l[j]
    index = bisect.bisect_left(l, sum)
    cnt += index - j - 1 i range(n-2) range n-2 n 2 for j in range(i+1, n-1):
    sum = l[i] + l[j]
    index = bisect.bisect_left(l, sum)
    cnt += index - j - 1 j range(i+1, n-1) range i+1 i 1 n-1 n 1 sum = l[i] + l[j] sum l[i] + l[j] l[i] l i l[j] l j index = bisect.bisect_left(l, sum) index bisect.bisect_left(l, sum) bisect.bisect_left bisect bisect_left l sum cnt += index - j - 1 cnt index - j - 1 index - j index j 1 print(cnt) print cnt index = bisect.bisect_left(l, sum) bisect.bisect_left(l, sum) index cnt = 0 0 cnt cnt += index - j - 1 index - j - 1 cnt sum = l[i] + l[j] l[i] + l[j] sum n = int(input()) int(input()) n l = list(map(int, input().split())) list(map(int, input().split())) l
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()
cnt = 0


for i in range(n-2):
  for j in range(i+1, n-1):
    sum = l[i] + l[j]
    index = bisect.bisect_left(l, sum)
    cnt += index - j - 1

print(cnt)