import sys

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

a = ri()
li = sorted(rl(), reverse=True)
cnt = 0
for i in range(a-2):
    for j in range(i+1, a-1):
        left = j+1
        right = a
        lii = li[i]
        lij = li[j]
        if lii >= lij + li[j+1]:
            continue
        while right-left > 1:
            t = (left + right)//2
            lit = li[t]
            if lii < lij + lit:
                left = t
            else:
                right = t
        cnt += left-j
print(cnt)
















 import sys sys ri = lambda: int(sys.stdin.readline()) ri lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rl = lambda: list(map(int, sys.stdin.readline().split())) rl lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split a = ri() a ri() ri li = sorted(rl(), reverse=True) li sorted(rl(), reverse=True) sorted rl() rl reverse=True reverse True cnt = 0 cnt 0 for i in range(a-2):
    for j in range(i+1, a-1):
        left = j+1
        right = a
        lii = li[i]
        lij = li[j]
        if lii >= lij + li[j+1]:
            continue
        while right-left > 1:
            t = (left + right)//2
            lit = li[t]
            if lii < lij + lit:
                left = t
            else:
                right = t
        cnt += left-j i range(a-2) range a-2 a 2 for j in range(i+1, a-1):
        left = j+1
        right = a
        lii = li[i]
        lij = li[j]
        if lii >= lij + li[j+1]:
            continue
        while right-left > 1:
            t = (left + right)//2
            lit = li[t]
            if lii < lij + lit:
                left = t
            else:
                right = t
        cnt += left-j j range(i+1, a-1) range i+1 i 1 a-1 a 1 left = j+1 left j+1 j 1 right = a right a lii = li[i] lii li[i] li i lij = li[j] lij li[j] li j if lii >= lij + li[j+1]:
            continue
         lii >= lij + li[j+1] lii lij + li[j+1] lij li[j+1] li j+1 j 1 continue while right-left > 1:
            t = (left + right)//2
            lit = li[t]
            if lii < lij + lit:
                left = t
            else:
                right = t
         right-left > 1 right-left right left 1 t = (left + right)//2 t (left + right)//2 left + right left right 2 lit = li[t] lit li[t] li t if lii < lij + lit:
                left = t
            else:
                right = t
         lii < lij + lit lii lij + lit lij lit left = t left t right = t right t cnt += left-j cnt left-j left j print(cnt) print cnt t = (left + right)//2 (left + right)//2 t ri = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ri lii = li[i] li[i] lii cnt = 0 0 cnt rl = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) rl left = j+1 j+1 left right = a a right li = sorted(rl(), reverse=True) sorted(rl(), reverse=True) li a = ri() ri() a left = t t left cnt += left-j left-j cnt right = t t right lit = li[t] li[t] lit lij = li[j] li[j] lij
import sys

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

a = ri()
li = sorted(rl(), reverse=True)
cnt = 0
for i in range(a-2):
    for j in range(i+1, a-1):
        left = j+1
        right = a
        lii = li[i]
        lij = li[j]
        if lii >= lij + li[j+1]:
            continue
        while right-left > 1:
            t = (left + right)//2
            lit = li[t]
            if lii < lij + lit:
                left = t
            else:
                right = t
        cnt += left-j
print(cnt)

















