

def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    L = read_ints()
    L.sort()
    answer = 0
    for i in range(2, N):
        for j in range(1, i):
            start, end = -1, j
            while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
            answer += j-end
    return answer


if __name__ == '__main__':
    print(solve()) def read_int():
    return int(input().strip()) read_int return int(input().strip()) int(input().strip()) int input().strip() ().strip () input strip def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints return list(map(int, input().strip().split(' '))) list(map(int, input().strip().split(' '))) list map(int, input().strip().split(' ')) map int input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' def solve():
    N = read_int()
    L = read_ints()
    L.sort()
    answer = 0
    for i in range(2, N):
        for j in range(1, i):
            start, end = -1, j
            while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
            answer += j-end
    return answer solve N = read_int() N read_int() read_int L = read_ints() L read_ints() read_ints L.sort() L.sort L sort answer = 0 answer 0 for i in range(2, N):
        for j in range(1, i):
            start, end = -1, j
            while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
            answer += j-end
     i range(2, N) range 2 N for j in range(1, i):
            start, end = -1, j
            while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
            answer += j-end
     j range(1, i) range 1 i start, end = -1, j start -1 end j while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
             end-start > 1 end-start end start 1 mid = start+(end-start)//2 mid start+(end-start)//2 start (end-start)//2 end-start end start 2 if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
             L[i]-L[j] < L[mid] L[i]-L[j] L[i] L i L[j] L j L[mid] L mid end = mid end mid start = mid start mid answer += j-end answer j-end j end return answer answer if __name__ == '__main__':
    print(solve()) __name__ == '__main__' __name__ '__main__' print(solve()) print solve() solve def read_ints():
    return list(map(int, input().strip().split(' '))) def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints def read_int():
    return int(input().strip()) def read_int():
    return int(input().strip()) read_int def solve():
    N = read_int()
    L = read_ints()
    L.sort()
    answer = 0
    for i in range(2, N):
        for j in range(1, i):
            start, end = -1, j
            while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
            answer += j-end
    return answer def solve():
    N = read_int()
    L = read_ints()
    L.sort()
    answer = 0
    for i in range(2, N):
        for j in range(1, i):
            start, end = -1, j
            while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
            answer += j-end
    return answer solve


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    L = read_ints()
    L.sort()
    answer = 0
    for i in range(2, N):
        for j in range(1, i):
            start, end = -1, j
            while end-start > 1:
                mid = start+(end-start)//2
                if L[i]-L[j] < L[mid]: # valid
                    end = mid
                else:
                    start = mid
            answer += j-end
    return answer


if __name__ == '__main__':
    print(solve())
