import bisect


def LI():
    return list(map(int, input().split()))


N = int(input())
L = LI()
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        ind = bisect.bisect_right(L, L[i]-L[j])
        if ind < j:
            ans += j-ind
print(ans) import bisect bisect def LI():
    return list(map(int, input().split())) LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N = int(input()) N int(input()) int input() input L = LI() L LI() LI L.sort() L.sort L sort ans = 0 ans 0 for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        ind = bisect.bisect_right(L, L[i]-L[j])
        if ind < j:
            ans += j-ind i range(N-1, 1, -1) range N-1 N 1 1 -1 for j in range(i-1, 0, -1):
        ind = bisect.bisect_right(L, L[i]-L[j])
        if ind < j:
            ans += j-ind j range(i-1, 0, -1) range i-1 i 1 0 -1 ind = bisect.bisect_right(L, L[i]-L[j]) ind bisect.bisect_right(L, L[i]-L[j]) bisect.bisect_right bisect bisect_right L L[i]-L[j] L[i] L i L[j] L j if ind < j:
            ans += j-ind ind < j ind j ans += j-ind ans j-ind j ind print(ans) print ans ans += j-ind j-ind ans L = LI() LI() L ans = 0 0 ans ind = bisect.bisect_right(L, L[i]-L[j]) bisect.bisect_right(L, L[i]-L[j]) ind N = int(input()) int(input()) N def LI():
    return list(map(int, input().split())) def LI():
    return list(map(int, input().split())) LI
import bisect


def LI():
    return list(map(int, input().split()))


N = int(input())
L = LI()
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        ind = bisect.bisect_right(L, L[i]-L[j])
        if ind < j:
            ans += j-ind
print(ans)
