def resolve():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    # print(L)
    ans = 0
    import bisect
    for i in range(N):
        for j in range(i+1, N):
            a, b = L[i], L[j]
            idx1 = bisect.bisect_left(L,b+a)
            idx2 = bisect.bisect_right(L,b-a)
            cnt = idx1 - idx2
            if idx2 <= i <= idx1:
                cnt -= 1
            if idx2 <= j <= idx1:
                cnt -= 1
            if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
    print(ans//3)
    

if '__main__' == __name__:
    resolve() def resolve():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    # print(L)
    ans = 0
    import bisect
    for i in range(N):
        for j in range(i+1, N):
            a, b = L[i], L[j]
            idx1 = bisect.bisect_left(L,b+a)
            idx2 = bisect.bisect_right(L,b-a)
            cnt = idx1 - idx2
            if idx2 <= i <= idx1:
                cnt -= 1
            if idx2 <= j <= idx1:
                cnt -= 1
            if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
    print(ans//3)
     resolve N = int(input()) N int(input()) int input() input L = sorted(list(map(int, input().split()))) L sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 import bisect bisect for i in range(N):
        for j in range(i+1, N):
            a, b = L[i], L[j]
            idx1 = bisect.bisect_left(L,b+a)
            idx2 = bisect.bisect_right(L,b-a)
            cnt = idx1 - idx2
            if idx2 <= i <= idx1:
                cnt -= 1
            if idx2 <= j <= idx1:
                cnt -= 1
            if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
     i range(N) range N for j in range(i+1, N):
            a, b = L[i], L[j]
            idx1 = bisect.bisect_left(L,b+a)
            idx2 = bisect.bisect_right(L,b-a)
            cnt = idx1 - idx2
            if idx2 <= i <= idx1:
                cnt -= 1
            if idx2 <= j <= idx1:
                cnt -= 1
            if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
     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 idx1 = bisect.bisect_left(L,b+a) idx1 bisect.bisect_left(L,b+a) bisect.bisect_left bisect bisect_left L b+a b a idx2 = bisect.bisect_right(L,b-a) idx2 bisect.bisect_right(L,b-a) bisect.bisect_right bisect bisect_right L b-a b a cnt = idx1 - idx2 cnt idx1 - idx2 idx1 idx2 if idx2 <= i <= idx1:
                cnt -= 1
             idx2 <= i <= idx1 idx2 <= i idx2 i idx1 cnt -= 1 cnt 1 if idx2 <= j <= idx1:
                cnt -= 1
             idx2 <= j <= idx1 idx2 <= j idx2 j idx1 cnt -= 1 cnt 1 if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
     cnt > 0 cnt 0 ans += cnt ans cnt print(ans//3) print ans//3 ans 3 if '__main__' == __name__:
    resolve() '__main__' == __name__ '__main__' __name__ resolve() resolve def resolve():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    # print(L)
    ans = 0
    import bisect
    for i in range(N):
        for j in range(i+1, N):
            a, b = L[i], L[j]
            idx1 = bisect.bisect_left(L,b+a)
            idx2 = bisect.bisect_right(L,b-a)
            cnt = idx1 - idx2
            if idx2 <= i <= idx1:
                cnt -= 1
            if idx2 <= j <= idx1:
                cnt -= 1
            if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
    print(ans//3)
     def resolve():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    # print(L)
    ans = 0
    import bisect
    for i in range(N):
        for j in range(i+1, N):
            a, b = L[i], L[j]
            idx1 = bisect.bisect_left(L,b+a)
            idx2 = bisect.bisect_right(L,b-a)
            cnt = idx1 - idx2
            if idx2 <= i <= idx1:
                cnt -= 1
            if idx2 <= j <= idx1:
                cnt -= 1
            if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
    print(ans//3)
     resolve
def resolve():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    # print(L)
    ans = 0
    import bisect
    for i in range(N):
        for j in range(i+1, N):
            a, b = L[i], L[j]
            idx1 = bisect.bisect_left(L,b+a)
            idx2 = bisect.bisect_right(L,b-a)
            cnt = idx1 - idx2
            if idx2 <= i <= idx1:
                cnt -= 1
            if idx2 <= j <= idx1:
                cnt -= 1
            if cnt > 0:
                ans += cnt
            # print("a: {} b: {} i: {} j: {} idx1: {}, idx2: {}".format(a, b, i, j, idx1, idx2))
            # print(ans)
    print(ans//3)
    

if '__main__' == __name__:
    resolve()