import sys, bisect

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

res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        a, b = L[i], L[j]
        c_l = bisect.bisect_left(L, a + b)
        
        if c_l <= j:
            continue
        
        # print(i, j, c_l)
        res += c_l - (j + 1)

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 range(N - 1):
    for j in range(i + 1, N):
        a, b = L[i], L[j]
        c_l = bisect.bisect_left(L, a + b)
        
        if c_l <= j:
            continue
        
        # print(i, j, c_l)
        res += c_l - (j + 1) i range(N - 1) range N - 1 N 1 for j in range(i + 1, N):
        a, b = L[i], L[j]
        c_l = bisect.bisect_left(L, a + b)
        
        if c_l <= j:
            continue
        
        # print(i, j, c_l)
        res += c_l - (j + 1) j range(i + 1, N) range i + 1 i 1 N a, b = L[i], L[j] a L[i] L i b L[j] L j c_l = bisect.bisect_left(L, a + b) c_l bisect.bisect_left(L, a + b) bisect.bisect_left bisect bisect_left L a + b a b if c_l <= j:
            continue
        
        # print(i, j, c_l)
         c_l <= j c_l j continue res += c_l - (j + 1) res c_l - (j + 1) c_l j + 1 j 1 print(res) print res b = L[i], L[j] L[j] b c_l = bisect.bisect_left(L, a + b) bisect.bisect_left(L, a + b) c_l N = int(input()) int(input()) N L = list(map(int, sys.stdin.readline().rsplit())) list(map(int, sys.stdin.readline().rsplit())) L a, b = L[i], L[j] L[i] a res += c_l - (j + 1) c_l - (j + 1) res res = 0 0 res
import sys, bisect

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

res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        a, b = L[i], L[j]
        c_l = bisect.bisect_left(L, a + b)
        
        if c_l <= j:
            continue
        
        # print(i, j, c_l)
        res += c_l - (j + 1)

print(res)
