import sys, bisect

N = int(input())
L = list(map(int, sys.stdin.readline().rsplit()))
L.sort()

res = 0
for i in reversed(range(1, N)):
    for j in reversed(range(i)):
        l = bisect.bisect_left(L, L[i] + L[j])
        # r = bisect.bisect_right(L, abs(L[i] - L[j]))
        
        res += l - 1 - i
        
print(res) import sys, bisect sys bisect N = int(input()) N int(input()) int input() input L = list(map(int, sys.stdin.readline().rsplit())) L list(map(int, sys.stdin.readline().rsplit())) list map(int, sys.stdin.readline().rsplit()) map int sys.stdin.readline().rsplit() sys.stdin.readline().rsplit sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rsplit L.sort() L.sort L sort res = 0 res 0 for i in reversed(range(1, N)):
    for j in reversed(range(i)):
        l = bisect.bisect_left(L, L[i] + L[j])
        # r = bisect.bisect_right(L, abs(L[i] - L[j]))
        
        res += l - 1 - i
         i reversed(range(1, N)) reversed range(1, N) range 1 N for j in reversed(range(i)):
        l = bisect.bisect_left(L, L[i] + L[j])
        # r = bisect.bisect_right(L, abs(L[i] - L[j]))
        
        res += l - 1 - i
         j reversed(range(i)) reversed range(i) range i l = bisect.bisect_left(L, L[i] + L[j]) l bisect.bisect_left(L, L[i] + L[j]) bisect.bisect_left bisect bisect_left L L[i] + L[j] L[i] L i L[j] L j res += l - 1 - i res l - 1 - i l - 1 l 1 i print(res) print res res += l - 1 - i l - 1 - i res res = 0 0 res l = bisect.bisect_left(L, L[i] + L[j]) bisect.bisect_left(L, L[i] + L[j]) l N = int(input()) int(input()) N L = list(map(int, sys.stdin.readline().rsplit())) list(map(int, sys.stdin.readline().rsplit())) L
import sys, bisect

N = int(input())
L = list(map(int, sys.stdin.readline().rsplit()))
L.sort()

res = 0
for i in reversed(range(1, N)):
    for j in reversed(range(i)):
        l = bisect.bisect_left(L, L[i] + L[j])
        # r = bisect.bisect_right(L, abs(L[i] - L[j]))
        
        res += l - 1 - i
        
print(res)
