import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(N):
    for b in range(a):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = a + 1
        ans += max(r - l, 0)
print(ans) import bisect bisect N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.sort() L.sort L sort ans = 0 ans 0 for a in range(N):
    for b in range(a):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = a + 1
        ans += max(r - l, 0) a range(N) range N for b in range(a):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = a + 1
        ans += max(r - l, 0) b range(a) range a ab = L[a] + L[b] ab L[a] + L[b] L[a] L a L[b] L b r = bisect.bisect_left(L, ab) r bisect.bisect_left(L, ab) bisect.bisect_left bisect bisect_left L ab l = a + 1 l a + 1 a 1 ans += max(r - l, 0) ans max(r - l, 0) max r - l r l 0 print(ans) print ans L = list(map(int, input().split())) list(map(int, input().split())) L ans += max(r - l, 0) max(r - l, 0) ans ans = 0 0 ans N = int(input()) int(input()) N l = a + 1 a + 1 l ab = L[a] + L[b] L[a] + L[b] ab r = bisect.bisect_left(L, ab) bisect.bisect_left(L, ab) r
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(N):
    for b in range(a):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = a + 1
        ans += max(r - l, 0)
print(ans)