from bisect import bisect_left


def can_make_tri(a, b, c):
    return a < b + c and b < c + a and c < a + b


N, *L = map(int, open(0).read().split())
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        pos = bisect_left(L, L[i] + L[j], lo=j + 1)
        ans += pos - (j + 1)
print(ans) from bisect import bisect_left def can_make_tri(a, b, c):
    return a < b + c and b < c + a and c < a + b can_make_tri return a < b + c and b < c + a and c < a + b a < b + c and b < c + a and c < a + b a < b + c and b < c + a a < b + c a b + c b c b < c + a b c + a c a c < a + b c a + b a b a a b b c c N, *L = map(int, open(0).read().split()) N map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split *L L L.sort() L.sort L sort ans = 0 ans 0 for i in range(N - 2):
    for j in range(i + 1, N - 1):
        pos = bisect_left(L, L[i] + L[j], lo=j + 1)
        ans += pos - (j + 1) i range(N - 2) range N - 2 N 2 for j in range(i + 1, N - 1):
        pos = bisect_left(L, L[i] + L[j], lo=j + 1)
        ans += pos - (j + 1) j range(i + 1, N - 1) range i + 1 i 1 N - 1 N 1 pos = bisect_left(L, L[i] + L[j], lo=j + 1) pos bisect_left(L, L[i] + L[j], lo=j + 1) bisect_left L L[i] + L[j] L[i] L i L[j] L j lo=j + 1 lo j + 1 j 1 ans += pos - (j + 1) ans pos - (j + 1) pos j + 1 j 1 print(ans) print ans ans = 0 0 ans N, *L = map(int, open(0).read().split()) map(int, open(0).read().split()) N ans += pos - (j + 1) pos - (j + 1) ans def can_make_tri(a, b, c):
    return a < b + c and b < c + a and c < a + b def can_make_tri(a, b, c):
    return a < b + c and b < c + a and c < a + b can_make_tri pos = bisect_left(L, L[i] + L[j], lo=j + 1) bisect_left(L, L[i] + L[j], lo=j + 1) pos
from bisect import bisect_left


def can_make_tri(a, b, c):
    return a < b + c and b < c + a and c < a + b


N, *L = map(int, open(0).read().split())
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        pos = bisect_left(L, L[i] + L[j], lo=j + 1)
        ans += pos - (j + 1)
print(ans)
