N = int(eval(input()))

# L = map(int, input().split())

SL = [int(i) for i in input().split()]

SL.sort()

# SL = sorted(list(L))

# SL = L.sort()

# print('SL', SL)

import bisect



ans = 0

for i in range(N-2):

    for j in range(i+1, N-1):

        ab = SL[i] + SL[j]

        # print(i, j)

        # print(SL[i], SL[j])

        r = bisect.bisect_left(SL, ab)

        l = j + 1

        # print('r', r)

        # print('l', l)

        # print('---')

        ans += max(0, r - l)



print(ans)
import bisect



def solve():

    N = int(eval(input()))

    L = [int(i) for i in input().split()]

    L.sort()

    total = 0

    for s in range(N-2):

        for m in range(s+1, N-1):

            l = bisect.bisect_left(L, L[s] + L[m], 0, N)

            if l > m: total += l - m - 1

    print(total)



    return 0



if __name__ == "__main__":

    solve()

N = int(eval(input()))
# L = map(int, input().split())
SL = [int(i) for i in input().split()]
SL.sort()
# SL = sorted(list(L))
# SL = L.sort()
# print('SL', SL)
import bisect

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        ab = SL[i] + SL[j]
        # print(i, j)
        # print(SL[i], SL[j])
        r = bisect.bisect_left(SL, ab)
        l = j + 1
        # print('r', r)
        # print('l', l)
        # print('---')
        ans += max(0, r - l)
print(ans)

import bisect


def solve():
    N = int(eval(input()))
    L = [int(i) for i in input().split()]
    L.sort()
    total = 0
    for s in range(N - 2):
        for m in range(s + 1, N - 1):
            l = bisect.bisect_left(L, L[s] + L[m], 0, N)
            if l > m:
                total += l - m - 1
    print(total)
    return 0


if __name__ == "__main__":
    solve()

-N = int(eval(input())) -# L = map(int, input().split()) -SL = [int(i) for i in input().split()] -SL.sort() -# SL = sorted(list(L)) -# SL = L.sort() -# print('SL', SL) -ans = 0 -for i in range(N - 2): -    for j in range(i + 1, N - 1): -        ab = SL[i] + SL[j] -        # print(i, j) -        # print(SL[i], SL[j]) -        r = bisect.bisect_left(SL, ab) -        l = j + 1 -        # print('r', r) -        # print('l', l) -        ans += max(0, r - l) -print(ans) + +def solve(): +    N = int(eval(input())) +    L = [int(i) for i in input().split()] +    L.sort() +    total = 0 +    for s in range(N - 2): +        for m in range(s + 1, N - 1): +            l = bisect.bisect_left(L, L[s] + L[m], 0, N) +            if l > m: +                total += l - m - 1 +    print(total) +    return 0 + + +if __name__ == "__main__": +    solve()